diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-08-24 17:26:38 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-08-26 04:09:54 +0200 |
commit | 4c8d16a3f48c6f7b77c94771c6aee6970578fa0b (patch) | |
tree | ae23a8fe31209c46b06f6f81d954688fd9440657 /src/utils | |
parent | aa22e6bd5e0b459450a987e96802541f7145b012 (diff) |
Ignore call signaling messages when not in a call
When a participant was not in the call but received an offer it was
ignored to avoid establishing a connection. However, all the other call
signaling messages were still processed. Due to this, if a participant
leaves the call but that fails in the server that participant still
receives all the participant updates (which also list that participant
as still in the call) and therefore that participant tries to establish
a connection with the other participants.
To prevent that now all call signaling messages are ignored when the
local participant is not in the call. Due to this the call signaling
message that changes the state from the local participant to
disconnected is now ignored as well, although that should not be a
problem given that (since the previous commmit) the call related data is
immediately cleared when the call is left, without waiting for the
signaling message.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/webrtc/webrtc.js | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/utils/webrtc/webrtc.js b/src/utils/webrtc/webrtc.js index f4894f14a..c84e83ce5 100644 --- a/src/utils/webrtc/webrtc.js +++ b/src/utils/webrtc/webrtc.js @@ -52,7 +52,7 @@ let ownScreenPeer = null let selfInCall = PARTICIPANT.CALL_FLAG.DISCONNECTED // Special variable to know when the local user explicitly joined and left the // call; this is needed to know when the user was kicked out from the call by a -// moderator. +// moderator and discard signaling events if received when not in the call. let localUserInCall = false const delayedConnectionToPeer = [] let callParticipantCollection = null @@ -531,12 +531,20 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local localCallParticipantModel = _localCallParticipantModel signaling.on('usersLeft', function(users) { + if (!localUserInCall) { + return + } + users.forEach(function(user) { delete usersInCallMapping[user] }) usersChanged(signaling, [], users) }) signaling.on('usersChanged', function(users) { + if (!localUserInCall) { + return + } + users.forEach(function(user) { const sessionId = user.sessionId || user.sessionid usersInCallMapping[sessionId] = user @@ -544,11 +552,19 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local usersInCallChanged(signaling, usersInCallMapping) }) signaling.on('allUsersChangedInCallToDisconnected', function() { + if (!localUserInCall) { + return + } + // "End meeting for all" was used, we don't have a user list but everyone disconnects from the call usersInCallMapping = {} usersInCallChanged(signaling, usersInCallMapping) }) signaling.on('participantFlagsChanged', function(event) { + if (!localUserInCall) { + return + } + /** * event { * roomid: "1609407087", @@ -567,6 +583,10 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local } }) signaling.on('usersInRoom', function(users) { + if (!localUserInCall) { + return + } + usersInCallMapping = {} users.forEach(function(user) { const sessionId = user.sessionId || user.sessionid @@ -623,6 +643,14 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local }) signaling.on('message', function(message) { + if (!localUserInCall) { + console.debug('Message received when not in the call, ignore', message.type, message) + + message.type = 'message-to-ignore' + + return + } + if (message.type === 'answer' && message.roomType === 'video' && delayedConnectionToPeer[message.from]) { clearInterval(delayedConnectionToPeer[message.from]) delete delayedConnectionToPeer[message.from] @@ -652,12 +680,6 @@ export default function initWebRtc(signaling, _callParticipantCollection, _local delete delayedConnectionToPeer[message.from] } - if (!selfInCall) { - console.debug('Offer received when not in the call, ignore') - - message.type = 'offer-to-ignore' - } - // MCU screen offers do not include the "broadcaster" property, // which is expected by SimpleWebRTC in screen offers from a remote // peer, so it needs to be explicitly added. |