瀏覽代碼

Clean up comments and changelog

Michelle Bu 11 年之前
父節點
當前提交
4890250b01
共有 3 個文件被更改,包括 20 次插入19 次删除
  1. 9 2
      changelog.md
  2. 1 7
      lib/dataconnection.js
  3. 10 10
      lib/negotiator.js

+ 9 - 2
changelog.md

@@ -1,12 +1,19 @@
 # PeerJS Changelog
 
 ## Version 0.3.0 (TBA)
+
+### Highlights
+* **Interoperable DataChannels and video/audio streams.**
 * Support for WebRTC video and audio streams.
-* **Deprecate the ability to assign labels to DataConnections.** They will
-  instead have a randomly-generated ID.
 * Add `util.supports.[FEATURE]` flags, which represent the WebRTC features
   supported by your browser.
+
+### Other changes
+* **Deprecate current Peer#connections format.** Connections will no longer be
+  keyed by label and will instead be in a list.
 * Additional logging levels (warnings, errors, all).
+* Additional logging functionality (`logFunction`).
+* SSL option now in config rather than automatic.
 
 ## Version 0.2.8 (1 July 2013)
 * Fix bug, no error on Firefox 24 due to missing error callback.

+ 1 - 7
lib/dataconnection.js

@@ -19,7 +19,7 @@ function DataConnection(peer, provider, options) {
   this.id = this.options.connectionId || DataConnection._idPrefix + util.randomToken();
 
   this.label = this.options.label || this.id;
-  this.metadata = this.options.metadata; // TODO: metadata could also be a part of the paylod.
+  this.metadata = this.options.metadata;
   this.serialization = this.options.serialization;
   this.reliable = this.options.reliable;
 
@@ -47,7 +47,6 @@ DataConnection.prototype.initialize = function(dc) {
 
 DataConnection.prototype._configureDataChannel = function() {
   var self = this;
-  // TODO: util.supports.binary
   if (util.supports.binary) {
     // Webkit doesn't support binary yet
     this._dc.binaryType = 'arraybuffer';
@@ -59,7 +58,6 @@ DataConnection.prototype._configureDataChannel = function() {
   }
 
   // Use the Reliable shim for non Firefox browsers
-  // TODO: util.supports.reliable
   if (!util.supports.reliable) {
     this._reliable = new Reliable(this._dc, util.debug);
   }
@@ -75,7 +73,6 @@ DataConnection.prototype._configureDataChannel = function() {
   }
   this._dc.onclose = function(e) {
     util.log('DataChannel closed for:', self.peer);
-    // TODO: remove connection from Peer as well!!
     self.close();
   };
 }
@@ -165,13 +162,10 @@ DataConnection.prototype.handleMessage = function(message) {
 
   switch (message.type) {
     case 'ANSWER':
-      // TODO: assert sdp exists.
-      // Should we pass `this`?
       // Forward to negotiator
       Negotiator.handleSDP(message.type, this, payload.sdp);
       break;
     case 'CANDIDATE':
-      // TODO
       Negotiator.handleCandidate(this, payload.candidate);
       break;
     default:

+ 10 - 10
lib/negotiator.js

@@ -1,8 +1,6 @@
 /**
  * Manages all negotiations between Peers.
  */
-// TODO: LOCKS.
-// TODO: FIREFOX new PC after offer made for DC.
 var Negotiator = {
   pcs: {
     data: {},
@@ -15,9 +13,7 @@ var Negotiator = {
 Negotiator._idPrefix = 'pc_';
 
 /** Returns a PeerConnection object set up correctly (for data, media). */
-// Options preceeded with _ are ones we add artificially.
 Negotiator.startConnection = function(connection, options) {
-  //Negotiator._addProvider(provider);
   var pc = Negotiator._getPeerConnection(connection, options);
 
   if (connection.type === 'media' && options._stream) {
@@ -55,9 +51,8 @@ Negotiator._getPeerConnection = function(connection, options) {
   var peerConnections = Negotiator.pcs[connection.type][connection.peer];
 
   var pc;
-  if (options.multiplex) {
-    // TODO: this doesn't work right now because we don't have PC ids.
-    // Find an existing PC to use.
+  // Not multiplexing while FF and Chrome have not-great support for it.
+  /*if (options.multiplex) {
     ids = Object.keys(peerConnections);
     for (var i = 0, ii = ids.length; i < ii; i += 1) {
       pc = peerConnections[ids[i]];
@@ -65,7 +60,8 @@ Negotiator._getPeerConnection = function(connection, options) {
         break; // We can go ahead and use this PC.
       }
     }
-  } else if (options.pc) { // Simplest case: PC id already provided for us.
+  } else */
+  if (options.pc) { // Simplest case: PC id already provided for us.
     pc = Negotiator.pcs[connection.type][connection.peer][options.pc];
   }
 
@@ -93,7 +89,12 @@ Negotiator._startPeerConnection = function(connection) {
   util.log('Creating RTCPeerConnection.');
 
   var id = Negotiator._idPrefix + util.randomToken();
-  pc = new RTCPeerConnection(connection.provider.options.config, {optional: [{RtpDataChannels: true}]});
+  pc = new RTCPeerConnection(connection.provider.options.config, {
+    optional: [{
+      RtpDataChannels: true,
+      DtlsSrtpKeyAgreement: true /* Firefox interop */
+    }]
+  });
   Negotiator.pcs[connection.type][connection.peer][id] = pc;
 
   Negotiator._setupListeners(connection, pc, id);
@@ -167,7 +168,6 @@ Negotiator._setupListeners = function(connection, pc, pc_id) {
   };
 }
 
-// TODO(michelle)
 Negotiator.cleanup = function(connection) {
   connection.close(); // Will fail safely if connection is already closed.
   util.log('Cleanup PeerConnection for ' + connection.peer);