Skip to content
Snippets Groups Projects
Commit a7ff8322 authored by lazorfuzz's avatar lazorfuzz
Browse files

Add shout/whisper methods to API

parent f5bbf60e
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ class LioWebRTC extends WildEmitter { ...@@ -19,6 +19,7 @@ class LioWebRTC extends WildEmitter {
remoteVideosEl: '', remoteVideosEl: '',
enableDataChannels: true, enableDataChannels: true,
autoRequestMedia: false, autoRequestMedia: false,
dataOnly: false,
autoRemoveVideos: true, autoRemoveVideos: true,
adjustPeerVolume: true, adjustPeerVolume: true,
peerVolumeWhenSpeaking: 0.25, peerVolumeWhenSpeaking: 0.25,
...@@ -120,8 +121,8 @@ class LioWebRTC extends WildEmitter { ...@@ -120,8 +121,8 @@ class LioWebRTC extends WildEmitter {
opts.debug = false; opts.debug = false;
this.webrtc = new WebRTC(opts); this.webrtc = new WebRTC(opts);
// attach a few methods from underlying lib to simple. // attach a few methods from underlying lib to liowebrtc.
['mute', 'unmute', 'pauseVideo', 'resumeVideo', 'pause', 'resume', 'sendToAll', 'sendDirectlyToAll', 'getPeers'].forEach((method) => { ['mute', 'unmute', 'pauseVideo', 'resumeVideo', 'pause', 'resume', 'sendToAll', 'sendDirectlyToAll', 'getPeers', 'shout', 'whisper'].forEach((method) => {
self[method] = self.webrtc[method].bind(self.webrtc); self[method] = self.webrtc[method].bind(self.webrtc);
}); });
...@@ -239,7 +240,7 @@ class LioWebRTC extends WildEmitter { ...@@ -239,7 +240,7 @@ class LioWebRTC extends WildEmitter {
if (data.type === 'volume') { if (data.type === 'volume') {
self.emit('remoteVolumeChange', data.payload, peer); self.emit('remoteVolumeChange', data.payload, peer);
} else { } else {
self.emit(data.type, data.payload, peer); self.emit('receivedPeerData', data.type, data.payload, peer);
} }
}); });
...@@ -320,8 +321,8 @@ class LioWebRTC extends WildEmitter { ...@@ -320,8 +321,8 @@ class LioWebRTC extends WildEmitter {
type, type,
enableDataChannels: self.config.enableDataChannels && type !== 'screen', enableDataChannels: self.config.enableDataChannels && type !== 'screen',
receiveMedia: { receiveMedia: {
offerToReceiveAudio: type !== 'screen' && self.config.receiveMedia.offerToReceiveAudio ? 1 : 0, offerToReceiveAudio: type !== 'screen' && !self.config.dataOnly && self.config.receiveMedia.offerToReceiveAudio ? 1 : 0,
offerToReceiveVideo: self.config.receiveMedia.offerToReceiveVideo offerToReceiveVideo: !self.config.dataOnly && self.config.receiveMedia.offerToReceiveVideo
} }
}); });
self.emit('createdPeer', peer); self.emit('createdPeer', peer);
......
...@@ -140,6 +140,14 @@ class WebRTC { ...@@ -140,6 +140,14 @@ class WebRTC {
} }
}); });
} }
shout(messageLabel, payload) {
sendDirectlyToAll(messageLabel, payload, 'liowebrtc');
}
whisper(peer, messageLabel, payload) {
peer.sendDirectly(messageLabel, payload);
}
} }
util.inherits(WebRTC, localMedia); util.inherits(WebRTC, localMedia);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment