Jelajahi Sumber

Add error event when negotiation fails

When negotiation fails, it fails silently, neither closed or error is
emitted on the connection. Thus, there is no way to know if the
connection negotiation failed.
Rolf Erik Lekang 10 tahun lalu
induk
melakukan
5be1e15e81
1 mengubah file dengan 5 tambahan dan 1 penghapusan
  1. 5 1
      lib/negotiator.js

+ 5 - 1
lib/negotiator.js

@@ -146,8 +146,12 @@ Negotiator._setupListeners = function(connection, pc, pc_id) {
 
 
   pc.oniceconnectionstatechange = function() {
   pc.oniceconnectionstatechange = function() {
     switch (pc.iceConnectionState) {
     switch (pc.iceConnectionState) {
-      case 'disconnected':
       case 'failed':
       case 'failed':
+        util.log('iceConnectionState is disconnected, closing connections to ' + peerId);
+        connection.emit('error', new Error('Negotiation of connection to ' + peerId + ' failed.'));
+        connection.close();
+        break;
+      case 'disconnected':
         util.log('iceConnectionState is disconnected, closing connections to ' + peerId);
         util.log('iceConnectionState is disconnected, closing connections to ' + peerId);
         connection.close();
         connection.close();
         break;
         break;