Comparing version 0.4.11 to 0.4.12
{ | ||
"name": "freedom", | ||
"version": "0.4.11", | ||
"version": "0.4.12", | ||
"homepage": "http://freedomjs.com", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -216,3 +216,6 @@ /*globals fdom:true */ | ||
// and PORT are a stun server hostname and port, respectively. | ||
["array", "string"] | ||
["array", "string"], | ||
// Whether to immediately initiate a connection before fulfilling return | ||
// promise. | ||
"boolean" | ||
] | ||
@@ -219,0 +222,0 @@ }, |
{ | ||
"name": "freedom", | ||
"description": "Embracing a distributed web", | ||
"version": "0.4.11", | ||
"version": "0.4.12", | ||
"homepage": "http://freedomjs.com", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -79,2 +79,4 @@ /*globals fdom:true, console, RTCPeerConnection, webkitRTCPeerConnection */ | ||
this.pc.addEventListener("signalingstatechange", function () { | ||
// TODO: come up with a better way to detect connection. We start out | ||
// as "stable" even before we are connected. | ||
if (this.pc.signalingState === "stable") { | ||
@@ -243,3 +245,4 @@ this.pcState = SimpleDataPeerState.CONNECTED; | ||
SimpleDataPeer.prototype.onNegotiationNeeded = function (e) { | ||
//console.log(this.peerName + ": " + "onNegotiationNeeded", this._pc, e); | ||
//console.log(this.peerName + ": " + "onNegotiationNeeded", | ||
// JSON.stringify(this._pc), e); | ||
if (this.pcState !== SimpleDataPeerState.DISCONNECTED) { | ||
@@ -277,2 +280,4 @@ // Negotiation messages are falsely requested for new data channels. | ||
logFail("setLocalDescription")); | ||
} else { | ||
console.error(this.peerName + ', onNegotiationNeeded failed'); | ||
} | ||
@@ -365,4 +370,4 @@ return; | ||
PeerConnection.prototype.setup = function (signallingChannelId, peerName, | ||
stunServers, continuation) { | ||
stunServers, initiateConnection, | ||
continuation) { | ||
this.peerName = peerName; | ||
@@ -422,5 +427,20 @@ var mocks = {RTCPeerConnection: this.RTCPeerConnection, | ||
this.signallingChannel.emit('ready'); | ||
this.peer.runWhenConnected(continuation); | ||
if (!initiateConnection) { | ||
this.peer.runWhenConnected(continuation); | ||
} | ||
}.bind(this)); | ||
if (initiateConnection) { | ||
// Setup a connection right away, then invoke continuation. | ||
console.log(this.peerName + ' initiating connection'); | ||
var channelId = 'hello' + Math.random().toString(); | ||
var openDataChannelContinuation = function(success, error) { | ||
if (error) { | ||
continuation(undefined, error); | ||
} else { | ||
this.closeDataChannel(channelId, continuation); | ||
} | ||
}.bind(this); | ||
this.openDataChannel(channelId, openDataChannelContinuation); | ||
} | ||
}; | ||
@@ -427,0 +447,0 @@ |
@@ -46,10 +46,14 @@ /* | ||
// The argument |channelId| is a freedom communication channel id to use | ||
// to open a peer connection. | ||
WebRTCTransportProvider.prototype.setup = function(name, channelId, continuation) { | ||
// console.log("TransportProvider.setup." + name); | ||
// The argument |signallingChannelId| is a freedom communication channel id to | ||
// use to open a peer connection. | ||
WebRTCTransportProvider.prototype.setup = function(name, signallingChannelId, | ||
continuation) { | ||
this.name = name; | ||
var promise = this.pc.setup(channelId, name, WebRTCTransportProvider.stun_servers); | ||
var promise = this.pc.setup(signallingChannelId, name, | ||
WebRTCTransportProvider.stun_servers, false); | ||
this._setup = true; | ||
promise.then(continuation); | ||
promise.then(continuation).catch(function() { | ||
console.error('Error setting up peerconnection'); | ||
continuation(undefined, 'Error setting up peerconnection'); | ||
}); | ||
}; | ||
@@ -56,0 +60,0 @@ |
@@ -101,3 +101,5 @@ function MockRTCIceCandidate() { | ||
} | ||
peerconnection.setup(PROXY, "setup peer", turnServers, setupCalled); | ||
peerconnection.setup(PROXY, "setup peer", turnServers, false, | ||
setupCalled); | ||
// Modify the SimpleDataPeer's pc object to change the state to CONNECTED, | ||
@@ -104,0 +106,0 @@ // so that SimpleDataPeer.runWhenConnected callbacks will be run. |
@@ -101,3 +101,4 @@ describe("unit: transport.webrtc.json", function () { | ||
"unit-tests", | ||
WebRTCTransportProvider.stun_servers); | ||
WebRTCTransportProvider.stun_servers, | ||
false); | ||
done(); | ||
@@ -104,0 +105,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
956560
17175