onRpc
Callable
- onRpc<K>(rpcName: K, listener: (player: Player, ...args: Parameters<ICustomClientServerRpc[K]>) => ReturnType<ICustomClientServerRpc[K]> | Promise<ReturnType<ICustomClientServerRpc[K]>>): void
- onRpc<K>(rpcName: Exclude<K, never>, listener: (player: Player, ...args: any[]) => any): void
Type parameters
- K: never
Subscribes to a client -> server RPC with the specified listener.
Example
Remarks
The return value of the listener function determines the response clients will receive. When returning multiple values, use an array. Returning an Error object will cause the promise on the client to throw an exception which has to be caught.