瀏覽代碼

set debug mode before throwing browser check errors

ericz 12 年之前
父節點
當前提交
e4deea10b8
共有 3 個文件被更改,包括 27 次插入23 次删除
  1. 15 12
      dist/peer.js
  2. 0 0
      dist/peer.min.js
  3. 12 11
      lib/peer.js

+ 15 - 12
dist/peer.js

@@ -1162,6 +1162,17 @@ function Peer(id, options) {
   if (!(this instanceof Peer)) return new Peer(id, options);
   EventEmitter.call(this);
 
+  
+  options = util.extend({
+    debug: false,
+    host: '0.peerjs.com',
+    port: 9000,
+    key: 'peerjs',
+    config: { 'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }] }
+  }, options);
+  this._options = options;
+  util.debug = options.debug;
+
   // First check if browser can use PeerConnection/DataChannels.
   // TODO: when media is supported, lower browser version limit and move DC
   // check to where`connect` is called.
@@ -1177,17 +1188,7 @@ function Peer(id, options) {
   if (options.host === '/') {
     options.host = window.location.hostname;
   }
-
-  options = util.extend({
-    debug: false,
-    host: '0.peerjs.com',
-    port: 9000,
-    key: 'peerjs',
-    config: { 'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }] }
-  }, options);
-  this._options = options;
-  util.debug = options.debug;
-
+  
   // Ensure alphanumeric_-
   if (id && !/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.exec(id)) {
     util.setZeroTimeout(function() {
@@ -1452,7 +1453,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;
   }

文件差異過大導致無法顯示
+ 0 - 0
dist/peer.min.js


+ 12 - 11
lib/peer.js

@@ -9,6 +9,17 @@ function Peer(id, options) {
   if (!(this instanceof Peer)) return new Peer(id, options);
   EventEmitter.call(this);
 
+  
+  options = util.extend({
+    debug: false,
+    host: '0.peerjs.com',
+    port: 9000,
+    key: 'peerjs',
+    config: { 'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }] }
+  }, options);
+  this._options = options;
+  util.debug = options.debug;
+
   // First check if browser can use PeerConnection/DataChannels.
   // TODO: when media is supported, lower browser version limit and move DC
   // check to where`connect` is called.
@@ -24,17 +35,7 @@ function Peer(id, options) {
   if (options.host === '/') {
     options.host = window.location.hostname;
   }
-
-  options = util.extend({
-    debug: false,
-    host: '0.peerjs.com',
-    port: 9000,
-    key: 'peerjs',
-    config: { 'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }] }
-  }, options);
-  this._options = options;
-  util.debug = options.debug;
-
+  
   // Ensure alphanumeric_-
   if (id && !/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.exec(id)) {
     util.setZeroTimeout(function() {

部分文件因文件數量過多而無法顯示