-
Notifications
You must be signed in to change notification settings - Fork 5
/
audiobridge.js
81 lines (69 loc) · 1.94 KB
/
audiobridge.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var janus = require('../');
var test = require('tape');
var randomName = require('random-name');
var session;
var baseUrl = require('./helpers/url');
var roomId;
test('create a new session', function(t) {
t.plan(2);
session = janus(baseUrl, function(err) {
t.ifError(err);
t.ok(session.id, 'got valid session id');
});
});
test('request the audiobridge plugin', function(t) {
t.plan(2);
session.activate('audiobridge', function(err) {
t.ifError(err);
t.ok(session.plugins.audiobridge, 'audiobridge plugin activated');
});
});
test('request a new room', function(t) {
var data = {
request: 'create',
description: 'My Awesome Test Room',
sampling: 16000,
record: false
};
t.plan(3);
session.audiobridge(data, function(err, response) {
t.ifError(err);
t.ok(response && response.audiobridge === 'created', 'created ok');
// save the room id
t.ok(roomId = response.room, 'got room id');
});
});
test('participant #1 join the new room', function(t) {
var data = {
request: 'join',
room: roomId,
display: randomName()
};
t.plan(4);
session.audiobridge(data, function(err, response) {
t.ifError(err);
t.ok(response && response.audiobridge === 'joined', 'joined ok');
t.equal(response.room, roomId, 'joined correct room');
t.equal(response.participants.length, 0, 'we are the first participant');
});
});
test('participant #2 join the new room', function(t) {
var data = {
request: 'join',
room: roomId,
display: randomName()
};
t.plan(4);
session.audiobridge(data, function(err, response) {
t.ifError(err);
t.ok(response && response.audiobridge === 'joined', 'joined ok');
t.equal(response.room, roomId, 'joined correct room');
t.equal(response.participants.length, 1, 'we are the second participant');
});
});
test('disconnect session', function(t) {
t.plan(1);
session.disconnect(function(err) {
t.ifError(err, 'ok');
});
});