The chat mode setting that the client has enabled.
Readonly
clientThe server-unique client ID for this client, see getNextClientId.
The version of the client's game. Sent with the identify packet.
Whether the client has successfully identified with the server.
Requires the client sending a ModdedHelloPacket (optional extension of 0x08 Hello)
The language that the client identified with.
Readonly
listenThe socket that this client connected to.
The last nonce that was received by this client.
Used to prevent duplicate packets with the same nonce.
The specific platform that this client is playing on.
This client's level/rank.
An array of the 8 latest packet nonces that were received from this client. Used to re-send acknowledgements that the client did not receive.
Readonly
remoteRemote information about this client.
Optional
roomThe room that this client is in.
The round-trip ping for this connection. Calculated very roughly by calculating the time it takes for each reliable packet to be acknowledged.
Whether a disconnect packet has been sent to this client.
Used to avoid an infinite loop of sending disconnect confirmations back and forth.
An array of the 8 latest packets that were sent to this client. Used to re-send packets that have not been acknowledged.
A map of messages that were sent out-of-order to allow the server to execute them when needed.
The username that this client identified with. Sent with the identify packet.
Readonly
workerThe server that this client is connected to.
The server that this client is connected to.
The socket that this client connected to.
Remote information about this client.
The server-unique client ID for this client, see getNextClientId.
Gracefully disconnect the client for this connection.
Note that this does not remove this connection from the server, see removeConnection.
// Disconnect a player for hacking.
await player.connection.disconnect(DisconnectReason.Hacking);
// Disconnect a player for a custom reason.
await player.connection.disconnect("You have been very naughty.");
Optional
reason: string | DisconnectReason | Record<string, string>The reason for why the client is being disconnected. Set to a string to use a custom message.
Rest
...message: string[]If the reason is custom, the message for why the client is being disconnected.
Get the next nonce to use for a reliable packet for this connection.
An incrementing nonce.
console.log(connection.getNextNonce()); // => 1
console.log(connection.getNextNonce()); // => 2
console.log(connection.getNextNonce()); // => 3
console.log(connection.getNextNonce()); // => 4
console.log(connection.getNextNonce()); // => 5
Get this client's player in the room that they're connected to.
connection.player.setName("obama");
Force this client to leave their current game. Primarily for destroy although exposed as a function for any other possible uses.
Sends a RemoveGame packet and does not immediately disconnect, although the client should do this shortly after receiving the message.
The reason to close the game.
Serialize and reliable or unreliably send a packet to this client.
For reliable packets, packets sent will be reliably recorded and marked for re-sending if the client does not send an acknowledgement for the packet.
connection.sendPacket(
new ReliablePacket(
connection.getNextNonce(),
[
new HostGameMessage("ALBERT")
]
)
);
The root packet to send.
Generated using TypeDoc
A formatted address for this connection.
Example