Parcourir la source

oniceconnectionstatechange handler added, partially deals with #41 except for multiple DC

Michelle Bu il y a 12 ans
Parent
commit
336b07538b
3 fichiers modifiés avec 28 ajouts et 2 suppressions
  1. 14 1
      dist/peer.js
  2. 0 0
      dist/peer.min.js
  3. 14 1
      lib/connectionmanager.js

+ 14 - 1
dist/peer.js

@@ -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;
   }

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
dist/peer.min.js


+ 14 - 1
lib/connectionmanager.js

@@ -94,6 +94,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. */
@@ -175,7 +188,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;
   }

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff