Skip to content

Commit

Permalink
Merge pull request #7080 from nextcloud/fix-forced-reconnections-when…
Browse files Browse the repository at this point in the history
…-the-hpb-is-not-used

Fix forced reconnections when the HPB is not used
  • Loading branch information
nickvergessen authored Apr 6, 2022
2 parents c510d58 + 6d3df14 commit 43ccc65
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions 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 @@ -398,8 +400,9 @@ 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)
this.joinCall(this.currentCallToken, this.currentCallFlags)
this.leaveCall(this.currentCallToken, true).then(() => {
this._joinCallAgainOnceDisconnected = true
})
}

Signaling.Internal.prototype._sendMessageWithCallback = function(ev) {
Expand All @@ -424,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 @@ -470,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 43ccc65

Please sign in to comment.