This fully implements the new RPC feature in the Rust SDK and exposes it via FFI to other SDKs.
It has one slight rough edge as there is a new FFI dance necessary for method handling. The register_rpc_method FFI cannot store the original handler, so instead it registers a wrapper handler that dispatches into the dependent SDK to actually handle the method and then get a response or error that can be sent back up the wire. So the implementation in Node/Python/Unity/etc requires both storing the handlers locally and forwarding to FFI on registerRpcMethod. Then it waits for RpcMethodInvocationEvent and invokes its stored handlers, sending the response/error in RpcMethodInvocationRequest over FFI.
This is my first time working with Rust so lmk if I've done anything particularly wrong. The RpcHandler type in particular feels very complicated but maybe that's just Rust.
Base implementation verified with a new example. FFI implementation verified with Node implementation in https://github.com/livekit/node-sdks/pull/276. Both tested locally and against cloud.
This fully implements the new RPC feature in the Rust SDK and exposes it via FFI to other SDKs.
It has one slight rough edge as there is a new FFI dance necessary for method handling. The
register_rpc_method
FFI cannot store the original handler, so instead it registers a wrapper handler that dispatches into the dependent SDK to actually handle the method and then get a response or error that can be sent back up the wire. So the implementation in Node/Python/Unity/etc requires both storing the handlers locally and forwarding to FFI onregisterRpcMethod
. Then it waits forRpcMethodInvocationEvent
and invokes its stored handlers, sending the response/error inRpcMethodInvocationRequest
over FFI.This is my first time working with Rust so lmk if I've done anything particularly wrong. The RpcHandler type in particular feels very complicated but maybe that's just Rust.
Base implementation verified with a new example. FFI implementation verified with Node implementation in https://github.com/livekit/node-sdks/pull/276. Both tested locally and against cloud.