-
Notifications
You must be signed in to change notification settings - Fork 2
/
nf_webchannel.js
41 lines (36 loc) · 1.02 KB
/
nf_webchannel.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
define(function () {
var send = function(connector, channelId, message) {
return new Promise(function(resolve, reject) {
connector.send(channelId, message).then(function() {
resolve();
}, function(error) {
reject(error);
});
});
}
// Leave the session
var leave = function(connector) {
return new Promise(function(resolve, reject) {
try {
connector.disconnect();
resolve();
} catch (e) {
reject(e);
}
});
}
var create = function(name, connect, facade) {
return {
onMessage: function() {},
onLeaving: function() {},
onJoining: function() {},
id: name,
send: function(message) { return send(connect, name, message); },
leave: function() { return leave(connect); },
peers: []
}
}
return {
create: create
};
});