ExperimentalExperimental
Establishes the participant as a receiver for calls of the specified RPC method.
The name of the indicated RPC method
Will be invoked when an RPC request for this method is received
A promise that resolves when the method is successfully registered
room.localParticipant?.registerRpcMethod(
'greet',
async (data: RpcInvocationData) => {
console.log(`Received greeting from ${data.callerIdentity}: ${data.payload}`);
return `Hello, ${data.callerIdentity}!`;
}
);
The handler should return a Promise that resolves to a string.
If unable to respond within responseTimeout, the request will result in an error on the caller's side.
You may throw errors of type RpcError with a string message in the handler,
and they will be received on the caller's side with the message intact.
Other errors thrown in your handler will not be transmitted as-is, and will instead arrive to the caller as 1500 ("Application Error").
Experimental
Unregisters a previously registered RPC method.
The name of the RPC method to unregister
Methods the
rpcextension adds to the room.