-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPC implementation + FFI #461
Conversation
livekit/src/rtc_engine/mod.rs
Outdated
pub fn get_latest_join_response(&self) -> proto::JoinResponse { | ||
self.inner.latest_join_response.clone() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is unused, can you remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link doesn't work for me
livekit/src/rtc_engine/mod.rs
Outdated
@@ -167,6 +183,7 @@ struct EngineInner { | |||
lk_runtime: Arc<LkRuntime>, | |||
engine_tx: EngineEmitter, | |||
options: EngineOptions, | |||
latest_join_response: proto::JoinResponse, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this field
async fn perform_quantum_hypergeometric_series( | ||
room: &Arc<Room>, | ||
) -> Result<(), Box<dyn std::error::Error>> { | ||
println!("[{}] What's the quantum hypergeometric series of 42?", elapsed_time()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋🏻
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 livekit/node-sdks#276. Both tested locally and against cloud.