Michelle Bu 12 年之前
父节点
当前提交
b2017bbcff
共有 8 个文件被更改,包括 40 次插入30 次删除
  1. 1 1
      .gitignore
  2. 1 1
      .gitmodules
  3. 4 0
      changelog.md
  4. 16 13
      dist/peer.js
  5. 0 0
      dist/peer.min.js
  6. 2 2
      examples/helloworld.html
  7. 15 12
      lib/peer.js
  8. 1 1
      package.json

+ 1 - 1
.gitignore

@@ -11,6 +11,6 @@ pids
 logs
 results
 demo
-
+bower.json
 node_modules
 npm-debug.log

+ 1 - 1
.gitmodules

@@ -6,4 +6,4 @@
 	url = git://github.com/peers/js-binarypack.git
 [submodule "deps/reliable"]
 	path = deps/reliable
-	url = git@github.com:michellebu/reliable.git
+	url = git://github.com/michellebu/reliable.git

+ 4 - 0
changelog.md

@@ -1,5 +1,9 @@
 # PeerJS Changelog
 
+## Version 0.2.7 (28 May 2013)
+* Fix bug, no error when .disconnect called in before socket connection established.
+* Fix bug, failure to enter debug mode when aborting because browser not supported.
+
 ## Version 0.2.6 (2 May 2013)
 * Peer.browser to check browser type.
 * Update Reliable library and fix Reliable functionality in Chrome.

+ 16 - 13
dist/peer.js

@@ -1,4 +1,4 @@
-/*! peerjs.js build:0.2.5, development. Copyright(c) 2013 Michelle Bu <michelle@michellebu.com> */
+/*! peerjs.js build:0.2.7, development. Copyright(c) 2013 Michelle Bu <michelle@michellebu.com> */
 (function(exports){
 var binaryFeatures = {};
 binaryFeatures.useBlobBuilder = (function(){
@@ -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


+ 2 - 2
examples/helloworld.html

@@ -8,7 +8,7 @@
 <script>
   // Just for demo.
   console._log = console.log;
-  console.log = function() {
+  console.error = console.log = function() {
     var copy = Array.prototype.slice.call(arguments).join(' ');
     $('.log').append(copy + '<br>');
     console._log(copy);
@@ -16,7 +16,7 @@
 </script>
 
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> 
-<script type="text/javascript" src="http://cdn.peerjs.com/0/peer.js"></script>
+<script type="text/javascript" src="../dist/peer.js"></script>
 <script>
   // This is a very simple code example. See chat.html for a more involved
   // example.

+ 15 - 12
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() {
@@ -299,7 +300,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;
   }

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "peerjs",
-  "version": "0.2.5",
+  "version": "0.2.7",
   "description": "PeerJS client library",
   "devDependencies": {
     "uglify-js": "~1.3.4",

部分文件因为文件数量过多而无法显示