Getting started
Connect a Client
Establish a session, negotiate codec, and join your first room.
Connect a Client
Basic connection
async function () {
const = await ("ws://localhost:4000", {
: "your-project-id",
: "your-client-token",
});
const = await .("counter_plugin_room", { : "default" });
.("player.move", { : 10, : 4, : 12 });
.<{ : number }>("match.start", () => {
.(.);
});
}What happens during connect
- Socket opens.
- Client sends JSON handshake (
v, supported codecs, project, token). - Server validates auth and picks codec (MessagePack preferred).
- Server replies
handshake.ok. - SDK switches to negotiated codec for subsequent packets.
Connection options
connect(url, options) supports:
projectId,token- codec preference order
- reconnect policy (enabled by default)
- optional auto-join matched room behavior
See full signatures in TypeScript SDK.