Browse Source

binarypack module

Michelle Bu 12 years ago
parent
commit
0530bcb1e2
4 changed files with 14 additions and 3 deletions
  1. 3 0
      .gitmodules
  2. 1 0
      public/js/binarypack
  3. 1 1
      public/js/sink.js
  4. 9 2
      public/js/source.js

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "public/js/binarypack"]
+	path = public/js/binarypack
+	url = git@github.com:michellebu/js-binarypack.git

+ 1 - 0
public/js/binarypack

@@ -0,0 +1 @@
+Subproject commit d88e0869541b0295ec0b42fdd2b2b7caa6fe4867

+ 1 - 1
public/js/sink.js

@@ -57,7 +57,7 @@ SinkPeer.prototype.setupDataChannel = function() {
     console.log('SINK: ondatachannel triggered');
     dc.binaryType = "blob";
     dc.onmessage = function(e) {
-
+      console.log(e.data);
     };
     self._dc = dc;
   };

+ 9 - 2
public/js/source.js

@@ -82,10 +82,10 @@ SourcePeer.prototype.setupDataChannel = function(pc, target, cb) {
   pc.onconnection = function() {
     console.log('SOURCE: onconnection triggered.');
     var dc = pc.createDataChannel(self._name, {}, target);
-    self._dc[target] = dc;
+    self._dcs[target] = dc;
     dc.binaryType = 'blob';
     dc.onmessage = function(e) {
-      self.handleDataMessage(pc, e);
+      self.handleDataMessage(dc, e);
       // process e.data
     };
   };
@@ -100,6 +100,13 @@ SourcePeer.prototype.setupDataChannel = function(pc, target, cb) {
   cb();
 };
 
+// Handles a Datachannel message.
+SourcePeer.prototype.handleDataMessage = function(dc, e) {
+  console.log(e.data);
+
+}
+
 SourcePeer.prototype.on = function(code, cb) {
   // For enduser.
 };
+