Преглед изворни кода

util.supports placeholders

Michelle Bu пре 12 година
родитељ
комит
489e9791fb
2 измењених фајлова са 11 додато и 8 уклоњено
  1. 1 1
      deps/reliable
  2. 10 7
      lib/dataconnection.js

+ 1 - 1
deps/reliable

@@ -1 +1 @@
-Subproject commit 0bbaf986efa550ea261b33ae20e17d85fb5b5bfa
+Subproject commit 856406373194f62fe68407eb680caa289a202a99

+ 10 - 7
lib/dataconnection.js

@@ -1,10 +1,11 @@
 /**
  * Wraps a DataChannel between two Peers.
  */
-function DataConnection(peer, dc, options) {
-  if (!(this instanceof DataConnection)) return new DataConnection(peer, dc, options);
+function DataConnection(peer, options) {
+  if (!(this instanceof DataConnection)) return new DataConnection(peer, options);
   EventEmitter.call(this);
 
+  // TODO: perhaps default serialization should be binary-utf8?
   options = util.extend({
     serialization: 'binary'
   }, options);
@@ -18,17 +19,18 @@ function DataConnection(peer, dc, options) {
   this.peer = peer;
   this.reliable = options.reliable;
 
-  this._dc = dc;
+  /*this._dc = dc;
   if (this._dc) {
     this._configureDataChannel();
-  }
+  }*/
 };
 
 util.inherits(DataConnection, EventEmitter);
 
 DataConnection.prototype._configureDataChannel = function() {
   var self = this;
-  if (util.browserisms !== 'Webkit') {
+  // TODO: util.supports.binary
+  if (util.supports.binary) {
     // Webkit doesn't support binary yet
     this._dc.binaryType = 'arraybuffer';
   }
@@ -39,7 +41,8 @@ DataConnection.prototype._configureDataChannel = function() {
   };
 
   // Use the Reliable shim for non Firefox browsers
-  if (this.reliable && util.browserisms !== 'Firefox') {
+  // TODO: util.supports.reliable
+  if (!util.supports.reliable) {
     this._reliable = new Reliable(this._dc, util.debug);
   }
 
@@ -132,7 +135,7 @@ DataConnection.prototype.send = function(data) {
     var utf8 = (this.serialization === 'binary-utf8');
     var blob = util.pack(data, utf8);
     // DataChannel currently only supports strings.
-    if (util.browserisms === 'Webkit') {
+    if (!util.supports.binary) {
       util.blobToBinaryString(blob, function(str){
         self._dc.send(str);
       });