Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Sep 18, 2023
1 parent 8e582da commit 90b6482
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
7 changes: 3 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ members = [
"webrtc-sys",
"webrtc-sys/build",
]

[patch.crates-io]
ring = { git = "https://github.com/1Password/ring", branch = "1p/release-0.16" }
35 changes: 20 additions & 15 deletions livekit/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,12 @@ impl RoomSession {
)))?;
}
}
EngineEvent::Resuming(tx) => self.handle_resuming(tx).await,
EngineEvent::Resumed(tx) => self.handle_resumed(tx).await,
EngineEvent::SignalResumed(tx) => self.handle_signal_resumed(tx).await,
EngineEvent::Restarting(tx) => self.handle_restarting(tx).await,
EngineEvent::Restarted(tx) => self.handle_restarted(tx).await,
EngineEvent::SignalRestarted(tx) => self.handle_signal_restarted(tx).await,
EngineEvent::Resuming(tx) => self.handle_resuming(tx),
EngineEvent::Resumed(tx) => self.handle_resumed(tx),
EngineEvent::SignalResumed(tx) => self.handle_signal_resumed(tx),
EngineEvent::Restarting(tx) => self.handle_restarting(tx),
EngineEvent::Restarted(tx) => self.handle_restarted(tx),
EngineEvent::SignalRestarted(tx) => self.handle_signal_restarted(tx),
EngineEvent::Disconnected { reason } => self.handle_disconnected(reason),
EngineEvent::Data {
payload,
Expand Down Expand Up @@ -694,29 +694,34 @@ impl RoomSession {
}
}

async fn handle_resuming(self: &Arc<Self>, tx: oneshot::Sender<()>) {
fn handle_resuming(self: &Arc<Self>, tx: oneshot::Sender<()>) {
if self.update_connection_state(ConnectionState::Reconnecting) {
self.dispatcher.dispatch(&RoomEvent::Reconnecting);
}

let _ = tx.send(());
}

async fn handle_resumed(self: &Arc<Self>, tx: oneshot::Sender<()>) {
fn handle_resumed(self: &Arc<Self>, tx: oneshot::Sender<()>) {
self.update_connection_state(ConnectionState::Connected);
self.dispatcher.dispatch(&RoomEvent::Reconnected);

let _ = tx.send(());
}

async fn handle_signal_resumed(self: &Arc<Self>, tx: oneshot::Sender<()>) {
self.send_sync_state().await;
fn handle_signal_resumed(self: &Arc<Self>, tx: oneshot::Sender<()>) {
tokio::spawn({
let session = self.clone();
async move {
session.send_sync_state().await;

// Always send the sync state before continuing the reconnection (e.g: publisher offer)
let _ = tx.send(());
// Always send the sync state before continuing the reconnection (e.g: publisher offer)
let _ = tx.send(());
}
});
}

async fn handle_restarting(self: &Arc<Self>, tx: oneshot::Sender<()>) {
fn handle_restarting(self: &Arc<Self>, tx: oneshot::Sender<()>) {
// Remove existing participants/subscriptions on full reconnect
let participants = self.participants.read().clone();
for (_, participant) in participants.iter() {
Expand All @@ -731,14 +736,14 @@ impl RoomSession {
let _ = tx.send(());
}

async fn handle_restarted(self: &Arc<Self>, tx: oneshot::Sender<()>) {
fn handle_restarted(self: &Arc<Self>, tx: oneshot::Sender<()>) {
self.update_connection_state(ConnectionState::Connected);
self.dispatcher.dispatch(&RoomEvent::Reconnected);

let _ = tx.send(());
}

async fn handle_signal_restarted(self: &Arc<Self>, tx: oneshot::Sender<()>) {
fn handle_signal_restarted(self: &Arc<Self>, tx: oneshot::Sender<()>) {
let join_response = self.rtc_engine.last_info().join_response;
self.local_participant
.update_info(join_response.participant.unwrap()); // The sid may have changed
Expand Down

0 comments on commit 90b6482

Please sign in to comment.