Client Connection Process
Summary
How a Reactor client finds a room, connects, and joins it, from the developer-facing API to the connected state. It is part of the Reactor Technical Overview.
Starting a Connection
Most projects connect through the ksConnect component on the room object. It exposes:
Connect mode:
ONLINE(fetch the public room list from the backend, then connect),REMOTE(connect to a host and port you supply), orLOCAL(connect to a local server for testing).Protocol: TCP or Reliable UDP. WebGL builds force WebSockets.
Events:
OnGetRooms,OnConnect, andOnDisconnect.
You can also drive the flow in code. ksConnect.BeginConnect() starts it, and room.Connect(authArgs) connects to a specific room. In ONLINE mode the client first calls the backend for a room list (surfaced through OnGetRooms), then connects to a chosen ksRoomInfo.
If no
OnGetRoomshandler is registered, the client connects to the first room in the list. Register a handler when you want to choose the room yourself.
Authentication
A client authenticates with optional authentication arguments you pass to Connect. The server receives them in its OnAuthenticate handler, which can accept or reject the join and return custom data.
Connection Outcomes
The connect result carries a ConnectStatus. SUCCESS means the client joined. Failures fall into groups:
Network: timeout, refused, reset, aborted, invalid address, unsupported protocol.
Authentication: protocol mismatch, connection limit reached, handler timeout, or a value your server's authentication handler returned.
Discovery: the room list could not be fetched in
ONLINEmode.
Your OnConnect handler receives the status and the authentication result (its code and any data the server returned), so a rejected join can report why.
Disconnecting and Reconnecting
room.Disconnect() closes the connection. A graceful disconnect flushes queued messages first; an immediate disconnect drops the connection at once. Reactor does not reconnect on its own: handle OnDisconnect, clean up the old room, and call Connect again to retry.
Where to Go Next
The Backend: how the room list comes from the online services.
Ownership and Authority: what a joined player is allowed to change.
Authentication: sign players in and verify them on join.
Running Rooms Locally and Online: connect a first room end to end.
Last updated

