Permalink
Browse files

oniceconnectionstatechange handler added, partially deals with #41 ex…

…cept for multiple DC
  • Loading branch information...
michelle committed Apr 4, 2013
1 parent a41dcd7 commit 336b07538b51fb332c232ace08c6d6eb72a390f8
Showing with 29 additions and 3 deletions.
  1. +14 −1 dist/peer.js
  2. +1 −1 dist/peer.min.js
  3. +14 −1 lib/connectionmanager.js
View
@@ -1755,6 +1755,19 @@ ConnectionManager.prototype._setupIce = function() {
});
}
};
+ this.pc.oniceconnectionstatechange = function() {
+ if (!!self.pc && self.pc.iceConnectionState === 'disconnected') {
+ util.log('iceConnectionState is disconnected, closing connections to ' + this.peer);
+ self.close();
+ }
+ };
+ // Fallback for older Chrome impls.
+ this.pc.onicechange = function() {
+ if (!!self.pc && self.pc.iceConnectionState === 'disconnected') {
+ util.log('iceConnectionState is disconnected, closing connections to ' + this.peer);
+ self.close();
+ }
+ };
};
/** Set up onnegotiationneeded. */
@@ -1836,7 +1849,7 @@ ConnectionManager.prototype._makeAnswer = function() {
/** Clean up PC, close related DCs. */
ConnectionManager.prototype._cleanup = function() {
util.log('Cleanup ConnectionManager for ' + this.peer);
- if (!!this.pc && this.pc.readyState !== 'closed') {
+ if (!!this.pc && (this.pc.readyState !== 'closed' || this.pc.signalingState !== 'closed')) {
this.pc.close();
this.pc = null;
}
Oops, something went wrong.

0 comments on commit 336b075

Please sign in to comment.