|
@@ -1,5 +1,5 @@
|
|
|
/**
|
|
|
- * A DataChannel|PeerConnection between two Peers.
|
|
|
+ * Wraps a DataChannel between two Peers.
|
|
|
*/
|
|
|
function DataConnection(id, peer, socket, options) {
|
|
|
if (!(this instanceof DataConnection)) return new DataConnection(options);
|
|
@@ -38,10 +38,6 @@ DataConnection.prototype.initialize = function(id, socket) {
|
|
|
if (!!socket) {
|
|
|
this._socket = socket;
|
|
|
}
|
|
|
- // Firefoxism: connectDataConnection ports.
|
|
|
- /*if (util.browserisms === 'Firefox') {
|
|
|
- this._firefoxPortSetup();
|
|
|
- }*/
|
|
|
|
|
|
// Set up PeerConnection.
|
|
|
this._startPeerConnection();
|
|
@@ -63,11 +59,6 @@ DataConnection.prototype.initialize = function(id, socket) {
|
|
|
this.handleSDP(this._sdp, 'OFFER');
|
|
|
}
|
|
|
|
|
|
- // Makes offer if Firefox
|
|
|
- /*if (util.browserisms === 'Firefox') {
|
|
|
- this._firefoxAdditional();
|
|
|
- }*/
|
|
|
-
|
|
|
// No-op this.
|
|
|
this.initialize = function() {};
|
|
|
};
|
|
@@ -134,24 +125,6 @@ DataConnection.prototype._setupIce = function() {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-/*DataConnection.prototype._firefoxPortSetup = function() {
|
|
|
- if (!DataConnection.usedPorts) {
|
|
|
- DataConnection.usedPorts = [];
|
|
|
- }
|
|
|
- this.localPort = util.randomPort();
|
|
|
- while (DataConnection.usedPorts.indexOf(this.localPort) != -1) {
|
|
|
- this.localPort = util.randomPort();
|
|
|
- }
|
|
|
- this.remotePort = util.randomPort();
|
|
|
- while (this.remotePort === this.localPort ||
|
|
|
- DataConnection.usedPorts.indexOf(this.localPort) != -1) {
|
|
|
- this.remotePort = util.randomPort();
|
|
|
- }
|
|
|
- DataConnection.usedPorts.push(this.remotePort);
|
|
|
- DataConnection.usedPorts.push(this.localPort);
|
|
|
-}*/
|
|
|
-
|
|
|
DataConnection.prototype._configureDataChannel = function() {
|
|
|
var self = this;
|
|
|
|
|
@@ -178,18 +151,6 @@ DataConnection.prototype._configureDataChannel = function() {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-/** Decide whether to handle Firefoxisms. */
|
|
|
-/*DataConnection.prototype._firefoxAdditional = function() {
|
|
|
- var self = this;
|
|
|
- getUserMedia({ audio: true, fake: true }, function(s) {
|
|
|
- self._pc.addStream(s);
|
|
|
- if (self._originator) {
|
|
|
- self._makeOffer();
|
|
|
- }
|
|
|
- }, function(err) { util.log('Could not getUserMedia'); });
|
|
|
-};*/
|
|
|
-
|
|
|
DataConnection.prototype._makeOffer = function() {
|
|
|
var self = this;
|
|
|
this._pc.createOffer(function(offer) {
|
|
@@ -328,18 +289,7 @@ DataConnection.prototype.handleSDP = function(sdp, type) {
|
|
|
var self = this;
|
|
|
this._pc.setRemoteDescription(sdp, function() {
|
|
|
util.log('Set remoteDescription: ' + type);
|
|
|
- // Firefoxism
|
|
|
- /**if (type === 'ANSWER' && util.browserisms === 'Firefox') {
|
|
|
- self._pc.connectDataConnection(self.localPort, self.remotePort);
|
|
|
- self._socket.send({
|
|
|
- type: 'PORT',
|
|
|
- dst: self.peer,
|
|
|
- payload: {
|
|
|
- remote: self.localPort,
|
|
|
- local: self.remotePort
|
|
|
- }
|
|
|
- });
|
|
|
- } else*/ if (type === 'OFFER') {
|
|
|
+ if (type === 'OFFER') {
|
|
|
self._makeAnswer();
|
|
|
}
|
|
|
}, function(err) {
|
|
@@ -360,15 +310,3 @@ DataConnection.prototype.handleLeave = function() {
|
|
|
util.log('Peer ' + this.peer + ' disconnected');
|
|
|
this.close();
|
|
|
};
|
|
|
-
|
|
|
-/*
|
|
|
-DataConnection.prototype.handlePort = function(message) {
|
|
|
- if (!DataConnection.usedPorts) {
|
|
|
- DataConnection.usedPorts = [];
|
|
|
- }
|
|
|
- DataConnection.usedPorts.push(message.local);
|
|
|
- DataConnection.usedPorts.push(message.remote);
|
|
|
- this._pc.connectDataConnection(message.local, message.remote);
|
|
|
-};
|
|
|
-*/
|
|
|
-
|