-
Notifications
You must be signed in to change notification settings - Fork 1
/
WebrtcSignaling.js
43 lines (43 loc) · 1.25 KB
/
WebrtcSignaling.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
"use strict";
/**
* WebRtcSiggnalling.
*
* Copyright 2017 Ahoo Studio.co.th.
*/
Object.defineProperty(exports, "__esModule", { value: true });
function withExchange(webrtcObject) {
return function exchange(message) {
var self = webrtcObject;
var fromId = message.from;
// const roomType = message.roomType;
var peer = self.peerManager.getPeers(fromId);
if (!peer) {
peer = self.peerManager.createPeer({
id: message.from,
// sid: message.sid,
// type: message.roomType,
offer: false,
}, self);
}
peer.handleMessage(message);
};
}
exports.withExchange = withExchange;
// send via signalling channel
function withSendMessage(webrtcObject) {
return function send(messageType, payload, optional) {
var self = webrtcObject;
if (!self.signalingSocket)
return;
var message = {
to: optional.to,
// sid: self.sid,
// broadcaster: this.broadcaster,
// roomType: self.type,
type: messageType,
payload: payload,
};
self.signalingSocket.emit('message', message);
};
}
exports.withSendMessage = withSendMessage;