Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonOehlman committed Oct 27, 2014
2 parents c24d23d + c0120a6 commit 696dec3
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 38 deletions.
10 changes: 10 additions & 0 deletions couple.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ function couple(pc, targetId, signaller, opts) {
signaller.removeListener('sdp', handleSdp);
signaller.removeListener('candidate', handleCandidate);
signaller.removeListener('negotiate', handleNegotiateRequest);

// remove listeners (version >= 5)
signaller.removeListener('message:sdp', handleSdp);
signaller.removeListener('message:candidate', handleCandidate);
signaller.removeListener('message:negotiate', handleNegotiateRequest);
}

function handleCandidate(data) {
Expand Down Expand Up @@ -195,9 +200,14 @@ function couple(pc, targetId, signaller, opts) {
signaller.on('sdp', handleSdp);
signaller.on('candidate', handleCandidate);

// listeners (signaller >= 5)
signaller.on('message:sdp', handleSdp);
signaller.on('message:candidate', handleCandidate);

// if this is a master connection, listen for negotiate events
if (isMaster) {
signaller.on('negotiate', handleNegotiateRequest);
signaller.on('message:negotiate', handleNegotiateRequest); // signaller >= 5
}

// when the connection closes, remove event handlers
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"messenger-memory": "^1.2.0",
"peerpair": "^1.0.0",
"rtc-media": "^1",
"rtc-signaller": "^3.1.1",
"rtc-switchboard": "^1.2.1",
"rtc-signaller": "^5.0.0",
"rtc-switchboard": "^2.0.0",
"rtc-switchboard-messenger": "^1.0.0",
"tape": "^3.0.1",
"testling": "^1",
"uuid": "^2.0.1",
Expand Down Expand Up @@ -46,4 +47,4 @@
"files": "test/all.js",
"server": "test/server.js"
}
}
}
7 changes: 4 additions & 3 deletions test/capture-close-localonly.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var couple = require('../couple');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var test = require('tape');
var rtc = require('..');
var conns = [];
Expand All @@ -22,8 +23,8 @@ test('create peer connections', function(t) {
test('create signallers', function(t) {
t.plan(2);

t.ok(signallers[0] = signaller(location.origin), 'created signaller a');
t.ok(signallers[1] = signaller(location.origin), 'created signaller b');
t.ok(signallers[0] = signaller(messenger), 'created signaller a');
t.ok(signallers[1] = signaller(messenger), 'created signaller b');
});

test('announce signallers', function(t) {
Expand Down Expand Up @@ -93,4 +94,4 @@ test('release references', function(t) {
monitors = [];
dcs = [];
t.pass('done');
});
});
7 changes: 4 additions & 3 deletions test/capture-close-signaller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var couple = require('../couple');
var cleanup = require('../cleanup');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var test = require('tape');
var rtc = require('..');
var conns = [];
Expand All @@ -24,10 +25,10 @@ module.exports = function(suiteName, ids) {
test(suiteName + ': create signallers', function(t) {
t.plan(4);

t.ok(signallers[0] = signaller(location.origin, { id: ids[0] }), 'created signaller a');
t.ok(signallers[0] = signaller(messenger, { id: ids[0] }), 'created signaller a');
t.equal(signallers[0].id, ids[0], 'id assigned');

t.ok(signallers[1] = signaller(location.origin, { id: ids[1] }), 'created signaller b');
t.ok(signallers[1] = signaller(messenger, { id: ids[1] }), 'created signaller b');
t.equal(signallers[1].id, ids[1], 'id assigned');
});

Expand Down Expand Up @@ -113,4 +114,4 @@ module.exports = function(suiteName, ids) {
dcs = [];
t.pass('done');
});
};
};
7 changes: 4 additions & 3 deletions test/capture-close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var couple = require('../couple');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var test = require('tape');
var rtc = require('..');
var conns = [];
Expand All @@ -22,8 +23,8 @@ test('create peer connections', function(t) {
test('create signallers', function(t) {
t.plan(2);

t.ok(signallers[0] = signaller(location.origin), 'created signaller a');
t.ok(signallers[1] = signaller(location.origin), 'created signaller b');
t.ok(signallers[0] = signaller(messenger), 'created signaller a');
t.ok(signallers[1] = signaller(messenger), 'created signaller b');
});

test('announce signallers', function(t) {
Expand Down Expand Up @@ -92,4 +93,4 @@ test('release references', function(t) {
monitors = [];
dcs = [];
t.pass('done');
});
});
7 changes: 4 additions & 3 deletions test/coupling-constraints.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var couple = require('../couple');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var test = require('tape');
var rtc = require('..');
var conns = [];
Expand All @@ -22,8 +23,8 @@ test('create peer connections', function(t) {
test('create signallers', function(t) {
t.plan(2);

t.ok(signallers[0] = signaller(location.origin), 'created signaller a');
t.ok(signallers[1] = signaller(location.origin), 'created signaller b');
t.ok(signallers[0] = signaller(messenger), 'created signaller a');
t.ok(signallers[1] = signaller(messenger), 'created signaller b');
});

test('announce signallers', function(t) {
Expand Down Expand Up @@ -95,4 +96,4 @@ test('release references', function(t) {
monitors = [];
dcs = [];
t.pass('done');
});
});
5 changes: 3 additions & 2 deletions test/coupling-customid.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var couple = require('../couple');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var test = require('tape');
var rtc = require('..');
var conns = [];
Expand All @@ -22,10 +23,10 @@ test('create peer connections', function(t) {
test('create signallers (using custom ids)', function(t) {
t.plan(4);

t.ok(signallers[0] = signaller(location.origin, { id: 1 }), 'created signaller a (id = 1)');
t.ok(signallers[0] = signaller(messenger, { id: 1 }), 'created signaller a (id = 1)');
t.equal(signallers[0].id, 1, 'id === 1');

t.ok(signallers[1] = signaller(location.origin, { id: 2 }), 'created signaller b');
t.ok(signallers[1] = signaller(messenger, { id: 2 }), 'created signaller b');
t.equal(signallers[1].id, 2, 'id === 2');
});

Expand Down
5 changes: 3 additions & 2 deletions test/coupling-reactive-doubleanswer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var couple = require('../couple');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var test = require('tape');
var rtc = require('..');
var conns = [];
Expand All @@ -22,8 +23,8 @@ test('create peer connections', function(t) {
test('create signallers', function(t) {
t.plan(2);

t.ok(signallers[0] = signaller(location.origin), 'created signaller a');
t.ok(signallers[1] = signaller(location.origin), 'created signaller b');
t.ok(signallers[0] = signaller(messenger), 'created signaller a');
t.ok(signallers[1] = signaller(messenger), 'created signaller b');
});

test('announce signallers', function(t) {
Expand Down
8 changes: 3 additions & 5 deletions test/coupling-reactive-randomdelay.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var couple = require('../couple');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var test = require('tape');
var rtc = require('..');
var conns = [];
Expand All @@ -9,13 +10,10 @@ var scope = [];
var messengers = [];
var dcs = [];
var roomId = require('uuid').v4();
var messenger = require('messenger-memory');
var messenger = require('./helpers/messenger');
var times = require('whisk/times');
var scope = [];
var messengers = [
messenger({ delay: Math.random() * 500, scope: scope }),
messenger({ delay: Math.random() * 500, scope: scope })
];
var messengers = [ messenger, messenger ];

// require('cog/logger').enable('*');

Expand Down
5 changes: 3 additions & 2 deletions test/coupling.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var couple = require('../couple');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var test = require('tape');
var rtc = require('..');
var conns = [];
Expand All @@ -22,8 +23,8 @@ test('create peer connections', function(t) {
test('create signallers', function(t) {
t.plan(2);

t.ok(signallers[0] = signaller(location.origin), 'created signaller a');
t.ok(signallers[1] = signaller(location.origin), 'created signaller b');
t.ok(signallers[0] = signaller(messenger), 'created signaller a');
t.ok(signallers[1] = signaller(messenger), 'created signaller b');
});

test('announce signallers', function(t) {
Expand Down
1 change: 1 addition & 0 deletions test/helpers/messenger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('rtc-switchboard-messenger')(location.origin);
14 changes: 4 additions & 10 deletions test/subtest-reactive-randomdelay-streams.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
var couple = require('../couple');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var MediaStream = require('../detect')('MediaStream');
var test = require('tape');
var rtc = require('..');
var messenger = require('messenger-memory');
var times = require('whisk/times');

module.exports = function(name, contexts, opts) {
var conns = [];
var signallers = [];
var monitors = [];
var scope = [];
var messengers = [];
var dcs = [];
var scope = [];

Expand All @@ -22,17 +21,10 @@ module.exports = function(name, contexts, opts) {
var maxDelay = ((opts || {}).maxDelay || 500) - minDelay;
var streamCount = (opts || {}).streamCount || 10;

var messengers = [
messenger({ delay: randomDelay, scope: scope }),
messenger({ delay: randomDelay, scope: scope })
];

function randomDelay() {
return minDelay + (Math.random() * maxDelay);
}

require('cog/logger').enable('rtc-validator');

test(name + ': create peer connections', function(t) {
t.plan(2);

Expand All @@ -42,7 +34,9 @@ module.exports = function(name, contexts, opts) {

test(name + ': create signallers', function(t) {
t.plan(2);
signallers = messengers.map(signaller);
signallers = times(2).map(function() {
return signaller(messenger);
});
t.ok(signallers[0], 'created signaller a');
t.ok(signallers[1], 'created signaller b');
});
Expand Down
5 changes: 3 additions & 2 deletions test/subtest-reactive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var couple = require('../couple');
var signaller = require('rtc-signaller');
var messenger = require('./helpers/messenger');
var test = require('tape');
var rtc = require('..');
var times = require('whisk/times');
Expand Down Expand Up @@ -33,8 +34,8 @@ module.exports = function(name, opts) {
test(name + ': create signallers', function(t) {
t.plan(2);

t.ok(signallers[0] = signaller(location.origin), 'created signaller a');
t.ok(signallers[1] = signaller(location.origin), 'created signaller b');
t.ok(signallers[0] = signaller(messenger), 'created signaller a');
t.ok(signallers[1] = signaller(messenger), 'created signaller b');
});

test(name + ': announce signallers', function(t) {
Expand Down

0 comments on commit 696dec3

Please sign in to comment.