Skip to content

Web-Socket Client

The client instance present on:

Note

This is the raw WebSocket connection coming from the ws package. There are more methods available which aren't encouraged to use along with Colyseus.

Properties

id: string

Unique id per client. When the same client connects with multiple browser tabs, the id will be the same for every connection.

sessionId: string

Unique id per session. Whilst you may have the same id for multiple sessions from the same client, the sessionId is always unique.

Note

In the client-side, you can find the sessionId in the room instance.

Methods

close(code?: number)

Force disconnection of the client with the server.

Tip

This will trigger room.onLeave event on the client-side.