Guides
RPC and Events
Choosing between request/response and fire-and-forget.
RPC and Events
Use RPC for operations that need correlation and explicit success/failure. Use events/messages for gameplay broadcasts and fire-and-forget actions.
Use RPC when
- you need success/failure response
- you need request correlation (
rid) - operation is not high-frequency
Use room messages when
- action is high-frequency gameplay input
- you do not need one response per action
- logic is room-scoped
RPC example
const response = await client.sendRPC("room.join_or_create", {
room_type: "counter_plugin_room",
room: "default",
});Room message example
room.send("player.move", { x: 10, y: 4, seq: 18 });Reliable vs unreliable
Nexis supports logical channel semantics over WebSocket:
- reliable: authoritative actions, confirmations, inventory, game results
- unreliable: transient updates like position/aim/input deltas
Practical split:
player.move-> often unreliableattack.commitorpurchase.confirm-> reliable
Typed RPC Request
async function () {
const = await <{ : string }>({
: 'room.join_or_create',
: { : 'counter_plugin_room', : 'default' },
});
if (. && .) .(..);
}