Prechádzať zdrojové kódy

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

Michelle Bu 12 rokov pred
rodič
commit
336b07538b
3 zmenil súbory, kde vykonal 28 pridanie a 2 odobranie
  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;
   }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 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;
   }

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov