@@ -213,19 +213,17 @@ pub(crate) async fn new_peer_connection_for_client(
213213 ..Default :: default ( )
214214 } ;
215215
216- peer_connection
217- . on_peer_connection_state_change ( Box :: new ( move |connection : RTCPeerConnectionState | {
216+ peer_connection. on_peer_connection_state_change ( Box :: new (
217+ move |connection : RTCPeerConnectionState | {
218218 log:: info!( "peer connection state change: {connection}" ) ;
219219 Box :: pin ( async move { } )
220- } ) )
221- . await ;
220+ } ,
221+ ) ) ;
222222
223- peer_connection
224- . on_signaling_state_change ( Box :: new ( move |ssc : RTCSignalingState | {
225- log:: info!( "new signaling state: {ssc}" ) ;
226- Box :: pin ( async move { } )
227- } ) )
228- . await ;
223+ peer_connection. on_signaling_state_change ( Box :: new ( move |ssc : RTCSignalingState | {
224+ log:: info!( "new signaling state: {ssc}" ) ;
225+ Box :: pin ( async move { } )
226+ } ) ) ;
229227
230228 let data_channel = peer_connection
231229 . create_data_channel ( "data" , Some ( data_channel_init) )
@@ -237,39 +235,37 @@ pub(crate) async fn new_peer_connection_for_client(
237235 let nc = negotiation_channel. clone ( ) ;
238236 let pc = Arc :: downgrade ( & peer_connection) ;
239237
240- negotiation_channel
241- . on_message ( Box :: new ( move |msg : DataChannelMessage | {
242- let wpc = pc. clone ( ) ;
243- let nc = nc. clone ( ) ;
244- Box :: pin ( async move {
245- let pc = match wpc. upgrade ( ) {
246- Some ( pc) => pc,
247- None => return ,
248- } ;
249- let sdp_vec = msg. data . to_vec ( ) ;
250- let maybe_err = async move {
251- let sdp = serde_json:: from_slice :: < RTCSessionDescription > ( & sdp_vec)
252- . map_err ( create_invalid_sdp_err) ?;
253- pc. set_remote_description ( sdp) . await ?;
254- let answer = pc. create_answer ( None ) . await ?;
255- pc. set_local_description ( answer) . await ?;
256- let local_description = pc
257- . local_description ( )
258- . await
259- . ok_or ( "No local description set" ) ;
260- let desc =
261- serde_json:: to_vec ( & local_description) . map_err ( create_invalid_sdp_err) ?;
262- let desc = Bytes :: copy_from_slice ( & desc) ;
263- nc. send ( & desc) . await
264- }
265- . await ;
238+ negotiation_channel. on_message ( Box :: new ( move |msg : DataChannelMessage | {
239+ let wpc = pc. clone ( ) ;
240+ let nc = nc. clone ( ) ;
241+ Box :: pin ( async move {
242+ let pc = match wpc. upgrade ( ) {
243+ Some ( pc) => pc,
244+ None => return ,
245+ } ;
246+ let sdp_vec = msg. data . to_vec ( ) ;
247+ let maybe_err = async move {
248+ let sdp = serde_json:: from_slice :: < RTCSessionDescription > ( & sdp_vec)
249+ . map_err ( create_invalid_sdp_err) ?;
250+ pc. set_remote_description ( sdp) . await ?;
251+ let answer = pc. create_answer ( None ) . await ?;
252+ pc. set_local_description ( answer) . await ?;
253+ let local_description = pc
254+ . local_description ( )
255+ . await
256+ . ok_or ( "No local description set" ) ;
257+ let desc =
258+ serde_json:: to_vec ( & local_description) . map_err ( create_invalid_sdp_err) ?;
259+ let desc = Bytes :: copy_from_slice ( & desc) ;
260+ nc. send ( & desc) . await
261+ }
262+ . await ;
266263
267- if let Err ( e) = maybe_err {
268- log:: error!( "Error processing sdp in negotiation channel: {e}" ) ;
269- }
270- } )
271- } ) )
272- . await ;
264+ if let Err ( e) = maybe_err {
265+ log:: error!( "Error processing sdp in negotiation channel: {e}" ) ;
266+ }
267+ } )
268+ } ) ) ;
273269
274270 if disable_trickle_ice {
275271 let offer = peer_connection. create_offer ( None ) . await ?;
0 commit comments