@@ -293,24 +293,43 @@ void P2PClient::OnSignalingMessage(const std::string& message,
293
293
rtc::GetIntFromJsonObject (stop_info, " code" , &code);
294
294
rtc::GetStringFromJsonObject (stop_info, " message" , &error);
295
295
296
+ if (code == kWebrtcIceGatheringPolicyUnsupported ) {
297
+ auto pcc = that->GetPeerConnectionChannel (remote_id);
298
+ std::shared_ptr<LocalStream> stream = pcc->GetLatestLocalStream ();
299
+ std::function<void ()> success_callback =
300
+ pcc->GetLatestPublishSuccessCallback ();
301
+ std::function<void (std::unique_ptr<Exception>)> failure_callback =
302
+ pcc->GetLatestPublishFailureCallback ();
303
+ pcc->SetAbandoned ();
304
+ {
305
+ const std::lock_guard<std::mutex> lock (that->pc_channels_mutex_ );
306
+ that->pc_channels_ .erase (remote_id);
307
+ }
308
+
309
+ auto new_pcc = that->GetPeerConnectionChannel (remote_id);
310
+ new_pcc->Publish (stream, success_callback, failure_callback);
311
+ return ;
312
+ }
296
313
auto pcc = that->GetPeerConnectionChannel (remote_id);
297
- std::shared_ptr<LocalStream> stream = pcc->GetLatestLocalStream ();
298
- std::function<void ()> success_callback =
299
- pcc->GetLatestPublishSuccessCallback ();
300
- std::function<void (std::unique_ptr<Exception>)> failure_callback =
301
- pcc->GetLatestPublishFailureCallback ();
302
314
// Don't send stop to remote.
303
315
pcc->SetAbandoned ();
304
-
305
316
{
306
317
const std::lock_guard<std::mutex> lock (that->pc_channels_mutex_ );
307
318
that->pc_channels_ .erase (remote_id);
308
319
}
309
320
310
- auto new_pcc = that->GetPeerConnectionChannel (remote_id);
311
- new_pcc->Publish (stream, success_callback, failure_callback);
312
321
return ;
313
322
}
323
+ } else if (message.find (" \" type\" :\" chat-ua\" " ) != std::string::npos) {
324
+ // "chat-ua" is the 1st message of a new connection. If there is an old
325
+ // PCC exists, close it and create a new one.
326
+ auto pcc = that->GetPeerConnectionChannel (remote_id);
327
+ // Don't send stop to remote.
328
+ pcc->SetAbandoned ();
329
+ {
330
+ const std::lock_guard<std::mutex> lock (that->pc_channels_mutex_ );
331
+ that->pc_channels_ .erase (remote_id);
332
+ }
314
333
}
315
334
// Secondly dispatch the message to pcc.
316
335
auto pcc = that->GetPeerConnectionChannel (remote_id);
0 commit comments