From 663537e988719291a9297d6f26a3fd712bba1223 Mon Sep 17 00:00:00 2001 From: lazorfuzz <leontosy@gmail.com> Date: Thu, 6 Dec 2018 18:16:00 -0800 Subject: [PATCH] Only send ping when constraints are valid --- README.md | 2 +- src/liowebrtc.js | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index aa4830e..69de190 100644 --- a/README.md +++ b/README.md @@ -272,7 +272,7 @@ export default Party; muted: true // mute local video stream to prevent echo } ``` - - `object network` - *optional* options for setting minimum and maximum peers to connect to. + - `object constraints` - *optional* options for setting minimum and maximum peers to connect to. Defaults to ```javascript { diff --git a/src/liowebrtc.js b/src/liowebrtc.js index 3ffdced..3780aa7 100644 --- a/src/liowebrtc.js +++ b/src/liowebrtc.js @@ -82,7 +82,7 @@ class LioWebRTC extends WildEmitter { sharemyscreen: message.roomType === 'screen' && !message.broadcaster, broadcaster: message.roomType === 'screen' && !message.broadcaster ? self.connection.getSessionid() : null, }); - if (this.config.dataOnly) { + if (this.config.dataOnly || this.config.constraints.maxPeers > 0) { this.sendPing(peer, peer.id, true); } else { peer.start(); @@ -425,7 +425,7 @@ class LioWebRTC extends WildEmitter { offerToReceiveVideo: !this.config.dataOnly && self.config.receiveMedia.offerToReceiveVideo ? 1 : 0, }, }); - if (this.config.dataOnly) { + if (this.config.dataOnly || this.config.constraints.maxPeers > 0) { this.sendPing(peer, peer.id, true); } else { peer.start(); @@ -479,9 +479,7 @@ class LioWebRTC extends WildEmitter { testReadiness() { const self = this; if (this.sessionReady) { - if (this.config.dataOnly || (!this.config.media.video && !this.config.media.audio)) { - self.emit('ready', self.connection.getSessionid()); - } else if (this.webrtc.localStreams.length > 0) { + if (this.config.dataOnly || (!this.config.media.video && !this.config.media.audio) || this.webrtc.localStreams.length > 0) { self.emit('ready', self.connection.getSessionid()); } } @@ -505,7 +503,7 @@ class LioWebRTC extends WildEmitter { offerToReceiveVideo: !this.config.dataOnly && this.config.receiveMedia.offerToReceiveVideo ? 1 : 0, }, }); - if (this.config.dataOnly) { + if (this.config.dataOnly || this.config.constraints.maxPeers > 0) { this.sendPing(peer, peerId, true); } else { peer.start(); -- GitLab