@@ -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 {
940954macro_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