File tree Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -392,21 +392,27 @@ class Signaling {
392392 sender.setParameters(parameters);
393393 */
394394 }
395- pc.onIceCandidate = (candidate) {
395+ pc.onIceCandidate = (candidate) async {
396396 if (candidate == null ) {
397397 print ('onIceCandidate: complete!' );
398398 return ;
399399 }
400- _send ('candidate' , {
401- 'to' : peerId,
402- 'from' : _selfId,
403- 'candidate' : {
404- 'sdpMLineIndex' : candidate.sdpMlineIndex,
405- 'sdpMid' : candidate.sdpMid,
406- 'candidate' : candidate.candidate,
407- },
408- 'session_id' : sessionId,
409- });
400+ // This delay is needed to allow enough time to try an ICE candidate
401+ // before skipping to the next one. 1 second is just an heuristic value
402+ // and should be thoroughly tested in your own environment.
403+ await Future .delayed (
404+ const Duration (seconds: 1 ),
405+ () => _send ('candidate' , {
406+ 'to' : peerId,
407+ 'from' : _selfId,
408+ 'candidate' : {
409+ 'sdpMLineIndex' : candidate.sdpMlineIndex,
410+ 'sdpMid' : candidate.sdpMid,
411+ 'candidate' : candidate.candidate,
412+ },
413+ 'session_id' : sessionId,
414+ })
415+ );
410416 };
411417
412418 pc.onIceConnectionState = (state) {};
You can’t perform that action at this time.
0 commit comments