ソースを参照

add some comments

ericz 12 年 前
コミット
48ad2b64d2
1 ファイル変更4 行追加1 行削除
  1. 4 1
      lib/dataconnection.js

+ 4 - 1
lib/dataconnection.js

@@ -29,6 +29,7 @@ util.inherits(DataConnection, EventEmitter);
 DataConnection.prototype._configureDataChannel = function() {
   var self = this;
   if (util.browserisms !== 'Webkit') {
+    // Webkit doesn't support binary yet
     this._dc.binaryType = 'arraybuffer';
   }
   this._dc.onopen = function() {
@@ -37,7 +38,7 @@ DataConnection.prototype._configureDataChannel = function() {
     self.emit('open');
   };
 
-  // Reliable.
+  // Use the Reliable shim for non Firefox browsers
   if (this.reliable && util.browserisms !== 'Firefox') {
     this._reliable = new Reliable(this._dc, util.debug);
   }
@@ -74,6 +75,7 @@ DataConnection.prototype._handleDataMessage = function(e) {
   var datatype = data.constructor;
   if (this.serialization === 'binary' || this.serialization === 'binary-utf8') {
     if (datatype === Blob) {
+      // Datatype should never be blob
       util.blobToArrayBuffer(data, function(ab) {
         data = util.unpack(ab);
         self.emit('data', data);
@@ -82,6 +84,7 @@ DataConnection.prototype._handleDataMessage = function(e) {
     } else if (datatype === ArrayBuffer) {
       data = util.unpack(data);
     } else if (datatype === String) {
+      // String fallback for binary data for browsers that don't support binary yet
       var ab = util.binaryStringToArrayBuffer(data);
       data = util.unpack(ab);
     }