NEXIS
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

  1. Socket opens.
  2. Client sends JSON handshake (v, supported codecs, project, token).
  3. Server validates auth and picks codec (MessagePack preferred).
  4. Server replies handshake.ok.
  5. 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.

On this page