Skip to content

Commit

Permalink
Fix dummy test datachannel callback behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma233 committed Mar 19, 2024
1 parent a1efaaa commit 2bf3d26
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/transport/src/connections/dummy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ impl DummyConnection {
}

self.callback().on_peer_connection_state_change(state).await;

// Simulate the behavior where the data channel is not opened immediately upon connection,
// but rather after a certain number of milliseconds.
if state == WebrtcConnectionState::Connected {
let cb = self.callback();
tokio::spawn(async move {
random_delay().await;
cb.on_data_channel_open().await;
});
}
}
}

Expand Down

0 comments on commit 2bf3d26

Please sign in to comment.