소스 검색

check if socket exists before attempting to close in disconnect

ericz 12 년 전
부모
커밋
a4a3f2d969
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      lib/peer.js

+ 3 - 1
lib/peer.js

@@ -299,7 +299,9 @@ Peer.prototype.destroy = function() {
  */
 Peer.prototype.disconnect = function() {
   if (!this.disconnected) {
-    this._socket.close();
+    if (!!this._socket) {
+      this._socket.close();
+    }
     this.id = null;
     this.disconnected = true;
   }