Skip to content

API Function defineRpc

github-actions[bot] edited this page Nov 24, 2026 · 1 revision

Function: defineRpc()

function defineRpc<S>(id, schema): RpcDef<S>;

Defined in: src/engine/net/rpc.ts:34

Declare an RPC type. Both ends of a connection must define the same RPCs, with the same schemas (the handshake checks), before they connect.

export const Ready = defineRpc("game.Ready", { team: u8, name: str });
Ready.send({ team: 1, name: "Anne" });                          // a client tells the server
for (const m of Ready.read()) assignTeam(m.connection, m.team); // in a server system

Type Parameters

S

S extends RpcSchema

Parameters

id

string

schema

S

Returns

RpcDef<S>

Clone this wiki locally