Browse Source

set debug mode before throwing browser check errors

ericz 12 years ago
parent
commit
e4deea10b8
3 changed files with 27 additions and 23 deletions
  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;
   }

File diff suppressed because it is too large
+ 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() {

Some files were not shown because too many files changed in this diff