Skip to content

Commit

Permalink
Fix not joining call again due to call flags in forced reconnections
Browse files Browse the repository at this point in the history
When the HPB is not used forcing a reconnection causes the call to be
left and then joined again. Although it was waited for the call to be
left first before joining again in some cases it could happen that,
after sending the join request but before receiving its response, the
"usersInRoom" event was received. In that case the call flags for the
participant will be "disconnected" (as at this point it is actually
disconnected), but as the join request was already sent it is seen as "a
moderator ended the call", and thus the call is left again. To prevent
that now it is explicitly waited for the "disconnected" flags to be
received and, then, the call is joined again.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Apr 1, 2022
1 parent 0167394 commit 6d3df14
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/utils/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ function Internal(settings) {
this.sendInterval = window.setInterval(function() {
this.sendPendingMessages()
}.bind(this), 500)

this._joinCallAgainOnceDisconnected = false
}

Internal.prototype = new Signaling.Base()
Expand Down Expand Up @@ -399,7 +401,7 @@ Signaling.Internal.prototype.forceReconnect = function(newSession, flags) {
// FIXME Naive reconnection routine; as the same session is kept peers
// must be explicitly ended before the reconnection is forced.
this.leaveCall(this.currentCallToken, true).then(() => {
this.joinCall(this.currentCallToken, this.currentCallFlags)
this._joinCallAgainOnceDisconnected = true
})
}

Expand All @@ -425,11 +427,14 @@ Signaling.Internal.prototype._sendMessages = function(messages) {
}

Signaling.Internal.prototype._joinRoomSuccess = function(token, sessionId) {
this._joinCallAgainOnceDisconnected = false

this.sessionId = sessionId
this._startPullingMessages()
}

Signaling.Internal.prototype._doLeaveRoom = function(token) {
this._joinCallAgainOnceDisconnected = false
}

Signaling.Internal.prototype.sendCallMessage = function(data) {
Expand Down Expand Up @@ -471,11 +476,20 @@ Signaling.Internal.prototype._startPullingMessages = function() {
}

result.data.ocs.data.forEach(message => {
let localParticipant

this._trigger('onBeforeReceiveMessage', [message])
switch (message.type) {
case 'usersInRoom':
this._trigger('usersInRoom', [message.data])
this._trigger('participantListChanged')

localParticipant = message.data.find(participant => participant.sessionId === this.sessionId)
if (this._joinCallAgainOnceDisconnected && !localParticipant.inCall) {
this._joinCallAgainOnceDisconnected = false
this.joinCall(this.currentCallToken, this.currentCallFlags)
}

break
case 'message':
if (typeof (message.data) === 'string') {
Expand Down

0 comments on commit 6d3df14

Please sign in to comment.