-
Notifications
You must be signed in to change notification settings - Fork 0
/
call.js
41 lines (32 loc) · 767 Bytes
/
call.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
var uuid = require('uuid');
var calls = [];
function Call() {
//this.id = uuid.v1();
this.id = "voova-room";
this.started = Date.now();
this.peers = [];
}
Call.prototype.toJSON = function() {
return {id: this.id, started: this.started, peers: this.peers};
};
Call.prototype.addPeer = function(peerId) {
this.peers.push(peerId);
};
Call.prototype.removePeer = function(peerId) {
var index = this.peers.lastIndexOf(peerId);
if (index !== -1) this.peers.splice(index, 1);
};
Call.create = function() {
var call = new Call();
calls.push(call);
return call;
};
Call.get = function(id) {
return (calls.filter(function(call) {
return id === call.id;
}) || [])[0];
};
Call.getAll = function() {
return calls;
};
module.exports = Call;