Skip to content

Commit

Permalink
peerConnection.addIceCandidates now requires success and failure call…
Browse files Browse the repository at this point in the history
…backs so added those (pointed out by Fabian BernHard). Also added success/failure callbacks to peerConnection.setRemoteDescription in places it had been missed.
  • Loading branch information
EricDavies committed Feb 12, 2015
1 parent d3f5134 commit 7ec94f5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
22 changes: 17 additions & 5 deletions api/easyrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ var Easyrtc = function() {
INTERNAL_ERR: "INTERNAL_ERR",
PEER_GONE: "PEER_GONE", // peer doesn't exist
ALREADY_CONNECTED: "ALREADY_CONNECTED",
"BAD_CREDENTIAL": "BAD_CREDENTIAL"
BAD_CREDENTIAL: "BAD_CREDENTIAL",
ICECANDIDATE_ERR: "ICECANDIDATE_ERROR"
};
this.apiVersion = "1.0.12";
/** Most basic message acknowledgment object */
Expand Down Expand Up @@ -3412,7 +3413,10 @@ var Easyrtc = function() {
sdp.sdp = sdpRemoteFilter(sdp.sdp);
}
var pc = peerConns[easyrtcid].pc;
pc.setRemoteDescription(new RTCSessionDescription(sdp));
pc.setRemoteDescription(new RTCSessionDescription(sdp), function(){},
function(message) {
self.showError(self.errCodes.INTERNAL_ERR, "set-remote-description: " + message);
});
}

}, "__gotAddedMediaStream");
Expand Down Expand Up @@ -4232,7 +4236,14 @@ var Easyrtc = function() {
});
}
pc = peerConns[caller].pc;
pc.addIceCandidate(candidate);

function iceAddSuccess() {}
function iceAddFailure(domError) {
easyrtc.showError(self.errCodes.ICECANDIDATE_ERR, "bad ice candidate (" + domError.name + "): " +
JSON.stringify(candidate));
}
pc.addIceCandidate(candidate, iceAddSuccess, iceAddFailure);

if (msgData.candidate.indexOf("typ relay") > 0) {
var ipAddress = msgData.candidate.match(/(udp|tcp) \d+ (\d+\.\d+\.\d+\.\d+)/i)[1];
self._turnServers[ipAddress] = true;
Expand Down Expand Up @@ -4376,7 +4387,9 @@ var Easyrtc = function() {
}
pc.connectDataConnection(5001, 5002); // these are like ids for data channels
}
});
}, function(message){
console.log("setRemoteDescription failed ", message);
});
} catch (smdException) {
console.log("setRemoteDescription failed ", smdException);
}
Expand Down Expand Up @@ -5091,7 +5104,6 @@ var Easyrtc = function() {
}
}
}
console.log("saw event data", eventData);
}
);

Expand Down
22 changes: 17 additions & 5 deletions api/easyrtc_int.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ var Easyrtc = function() {
INTERNAL_ERR: "INTERNAL_ERR",
PEER_GONE: "PEER_GONE", // peer doesn't exist
ALREADY_CONNECTED: "ALREADY_CONNECTED",
"BAD_CREDENTIAL": "BAD_CREDENTIAL"
BAD_CREDENTIAL: "BAD_CREDENTIAL",
ICECANDIDATE_ERR: "ICECANDIDATE_ERROR"
};
this.apiVersion = "1.0.12";
/** Most basic message acknowledgment object */
Expand Down Expand Up @@ -3229,7 +3230,10 @@ var Easyrtc = function() {
sdp.sdp = sdpRemoteFilter(sdp.sdp);
}
var pc = peerConns[easyrtcid].pc;
pc.setRemoteDescription(new RTCSessionDescription(sdp));
pc.setRemoteDescription(new RTCSessionDescription(sdp), function(){},
function(message) {
self.showError(self.errCodes.INTERNAL_ERR, "set-remote-description: " + message);
});
}

}, "__gotAddedMediaStream");
Expand Down Expand Up @@ -4049,7 +4053,14 @@ var Easyrtc = function() {
});
}
pc = peerConns[caller].pc;
pc.addIceCandidate(candidate);

function iceAddSuccess() {}
function iceAddFailure(domError) {
easyrtc.showError(self.errCodes.ICECANDIDATE_ERR, "bad ice candidate (" + domError.name + "): " +
JSON.stringify(candidate));
}
pc.addIceCandidate(candidate, iceAddSuccess, iceAddFailure);

if (msgData.candidate.indexOf("typ relay") > 0) {
var ipAddress = msgData.candidate.match(/(udp|tcp) \d+ (\d+\.\d+\.\d+\.\d+)/i)[1];
self._turnServers[ipAddress] = true;
Expand Down Expand Up @@ -4193,7 +4204,9 @@ var Easyrtc = function() {
}
pc.connectDataConnection(5001, 5002); // these are like ids for data channels
}
});
}, function(message){
console.log("setRemoteDescription failed ", message);
});
} catch (smdException) {
console.log("setRemoteDescription failed ", smdException);
}
Expand Down Expand Up @@ -4908,7 +4921,6 @@ var Easyrtc = function() {
}
}
}
console.log("saw event data", eventData);
}
);

Expand Down

0 comments on commit 7ec94f5

Please sign in to comment.