소스 검색

disconnect

Michelle Bu 11 년 전
부모
커밋
f15526bbfb
3개의 변경된 파일12개의 추가작업 그리고 11개의 파일을 삭제
  1. 6 5
      dist/peer.js
  2. 0 0
      dist/peer.min.js
  3. 6 6
      lib/dataconnection.js

+ 6 - 5
dist/peer.js

@@ -1689,13 +1689,14 @@ DataConnection.prototype._configureDataChannel = function() {
 }
 
 DataConnection.prototype._cleanup = function() {
-  if (this._dc && this._dc.readyState !== 'closed') {
+  if (this._dc.readyState !== 'closing' && this._dc.readyState !== 'closed') {
     this._dc.close();
-    this._dc = null;
+    this.open = false;
+    Negotiator.cleanup(this);
+    this.emit('close');
+  } else {
+    this.emit('error', new Error('The connection has already been closed'));
   }
-  this.open = false;
-  Negotiator.cleanup(this);
-  this.emit('close');
 }
 
 // Handles a DataChannel message.

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/peer.min.js


+ 6 - 6
lib/dataconnection.js

@@ -81,14 +81,14 @@ DataConnection.prototype._configureDataChannel = function() {
 }
 
 DataConnection.prototype._cleanup = function() {
-  if (this._dc && this._dc.readyState !== 'closed') {
-    console.log('closing', this._dc);
+  if (this._dc.readyState !== 'closing' && this._dc.readyState !== 'closed') {
     this._dc.close();
-    this._dc = null;
+    this.open = false;
+    Negotiator.cleanup(this);
+    this.emit('close');
+  } else {
+    this.emit('error', new Error('The connection has already been closed'));
   }
-  this.open = false;
-  Negotiator.cleanup(this);
-  this.emit('close');
 }
 
 // Handles a DataChannel message.

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.