diff --git a/assets/js/components/calls/callWindow.js b/assets/js/components/calls/callWindow.js index 2e4acdc5..af5210bf 100644 --- a/assets/js/components/calls/callWindow.js +++ b/assets/js/components/calls/callWindow.js @@ -679,6 +679,10 @@ ComunicWeb.components.calls.callWindow = { //Else we have to create peer ComunicWeb.components.calls.callWindow.createPeerConnection(call, member, false); } + + //Send ready message if the connection is not established yet + if(!call.streams["peer-" + member.userID].connected) + call.signalClient.sendReadyMessage(member.user_call_id); }); @@ -695,7 +699,8 @@ ComunicWeb.components.calls.callWindow = { createPeerConnection: function(call, member, isInitiator){ var peerConnection = { - peer: undefined + peer: undefined, + connected: false }; call.streams["peer-" + member.userID] = peerConnection; @@ -727,6 +732,10 @@ ComunicWeb.components.calls.callWindow = { peerConnection.video.remove(); } + peer.on("connect", function(){ + peerConnection.connected = true; + }); + peer.on("error", function(err){ console.error("Peer error !", err, member); @@ -750,11 +759,6 @@ ComunicWeb.components.calls.callWindow = { peer.on("stream", function(stream){ ComunicWeb.components.calls.callWindow.streamAvailable(call, member, stream); }); - - - //If this peer does not initialize connection, inform other peer we are ready - if(!isInitiator) - call.signalClient.sendReadyMessage(member.user_call_id); }, @@ -776,6 +780,10 @@ ComunicWeb.components.calls.callWindow = { if(member.userID > userID()) return; + //Check if peer connection is already being created + if(call.streams.hasOwnProperty("peer-" + member.userID)) + return; + this.createPeerConnection(call, member, true); },