浏览代码

make reliable a config option

ericz 12 年之前
父节点
当前提交
0a5cc4f313
共有 1 个文件被更改,包括 7 次插入6 次删除
  1. 7 6
      lib/connection.js

+ 7 - 6
lib/connection.js

@@ -4,9 +4,10 @@ function DataConnection(id, peer, socket, httpUrl, cb, options) {
 
   options = util.extend({
     config: { 'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }] },
-    socketOpen: false
+    socketOpen: false,
+    reliable: false
   }, options);
-  this.options = options;
+  this._options = options;
   
   this._id = id;
   this._peer = peer;
@@ -15,7 +16,7 @@ function DataConnection(id, peer, socket, httpUrl, cb, options) {
   this._httpUrl = httpUrl;
   this.metadata = options.metadata;
   this._socketOpen = options.socketOpen;
-  this._config = options.config;
+  
 
   // Set up socket handlers.
   this._socket = socket;
@@ -68,7 +69,7 @@ DataConnection.prototype._setupDataChannel = function() {
   var self = this;
   if (this._originator) {
     util.log('Creating data channel');
-    this._dc = this._pc.createDataChannel(this._peer, { reliable: false });
+    this._dc = this._pc.createDataChannel(this._peer, { reliable: this._options.reliable });
     this._configureDataChannel();
   } else {
     util.log('Listening for data channel');
@@ -83,8 +84,8 @@ DataConnection.prototype._setupDataChannel = function() {
 
 /** Starts a PeerConnection and sets up handlers. */
 DataConnection.prototype._startPeerConnection = function() {
-  util.log('Creating RTCPeerConnection: ', this._config);
-  this._pc = new RTCPeerConnection(this._config, { optional:[ { RtpDataChannels: true } ]});
+  util.log('Creating RTCPeerConnection');
+  this._pc = new RTCPeerConnection(this._options.config, { optional:[ { RtpDataChannels: true } ]});
 };