Skip to content

Commit 620613b

Browse files
authored
fix: correctly simulate force tcp/tls (#182)
* ffi v0.3.2 * fix: correctly simulate force tcp/tls
1 parent b157249 commit 620613b

4 files changed

Lines changed: 28 additions & 7 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

livekit/src/rtc_engine/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ impl RtcEngine {
212212
self.inner.wait_reconnection().await?;
213213
let handle = self.inner.running_handle.read().await;
214214
let session = &handle.as_ref().unwrap().session;
215-
session.simulate_scenario(scenario).await;
216-
Ok(())
215+
session.simulate_scenario(scenario).await
217216
}
218217

219218
pub async fn add_track(&self, req: proto::AddTrackRequest) -> EngineResult<proto::TrackInfo> {

livekit/src/rtc_engine/rtc_session.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl RtcSession {
289289
self.inner.wait_pc_connection().await
290290
}
291291

292-
pub async fn simulate_scenario(&self, scenario: SimulateScenario) {
292+
pub async fn simulate_scenario(&self, scenario: SimulateScenario) -> EngineResult<()> {
293293
self.inner.simulate_scenario(scenario).await
294294
}
295295

@@ -699,7 +699,16 @@ impl SessionInner {
699699
self.subscriber_pc.close();
700700
}
701701

702-
async fn simulate_scenario(&self, scenario: SimulateScenario) {
702+
async fn simulate_scenario(&self, scenario: SimulateScenario) -> EngineResult<()> {
703+
let simulate_leave = || {
704+
self.on_signal_event(proto::signal_response::Message::Leave(
705+
proto::LeaveRequest {
706+
reason: DisconnectReason::ClientInitiated as i32,
707+
can_reconnect: true,
708+
},
709+
))
710+
};
711+
703712
match scenario {
704713
SimulateScenario::SignalReconnect => {
705714
self.signal_client.close().await;
@@ -752,6 +761,8 @@ impl SessionInner {
752761
},
753762
))
754763
.await;
764+
765+
simulate_leave().await?
755766
}
756767
SimulateScenario::ForceTls => {
757768
self.signal_client
@@ -765,8 +776,11 @@ impl SessionInner {
765776
},
766777
))
767778
.await;
779+
780+
simulate_leave().await?
768781
}
769782
}
783+
Ok(())
770784
}
771785

772786
async fn publish_data(
@@ -940,7 +954,7 @@ impl SessionInner {
940954
macro_rules! make_rtc_config {
941955
($fncname:ident, $proto:ty) => {
942956
fn $fncname(value: $proto) -> RtcConfiguration {
943-
RtcConfiguration {
957+
let mut config = RtcConfiguration {
944958
ice_servers: {
945959
let mut servers = Vec::with_capacity(value.ice_servers.len());
946960
for ice_server in value.ice_servers.clone() {
@@ -954,7 +968,15 @@ macro_rules! make_rtc_config {
954968
},
955969
continual_gathering_policy: ContinualGatheringPolicy::GatherContinually,
956970
ice_transport_type: IceTransportsType::All,
971+
};
972+
973+
if let Some(client_configuration) = value.client_configuration {
974+
if client_configuration.force_relay() == proto::ClientConfigSetting::Enabled {
975+
config.ice_transport_type = IceTransportsType::Relay;
976+
}
957977
}
978+
979+
config
958980
}
959981
};
960982
}

0 commit comments

Comments
 (0)