Skip to content

Commit

Permalink
if we can't call _onMessage yet, delay all messages until we can
Browse files Browse the repository at this point in the history
and not just some of them discarding the others, so we
always apply all messages received in order the arrived
without omissions.

TODO: apply them when the conditions application requires become
true rather than depending on a timer poll.

Signed-off-by: Caolán McNamara <[email protected]>
Change-Id: I265b6ccb45e211c15c5f4daf9d6572fa051b68eb
  • Loading branch information
caolanm committed Sep 7, 2023
1 parent 855429d commit 8ba14ab
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions browser/src/core/Socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -1214,12 +1214,9 @@ app.definitions.Socket = L.Class.extend({
this._onHyperlinkClickedMsg(textMsg);
}

var msgDelayed = false;
if (!this._isReady() || !this._map._docLayer || this._delayedMessages.length || this._handlingDelayedMessages) {
msgDelayed = this._tryToDelayMessage(textMsg);
}

if (this._map._docLayer && !msgDelayed) {
this._delayMessage(textMsg);
} else {
this._map._docLayer._onMessage(textMsg, e.image);
}
},
Expand Down Expand Up @@ -1334,25 +1331,13 @@ app.definitions.Socket = L.Class.extend({
// var name = command.name; - ignored, we get the new name via the wopi's BaseFileName
},

_tryToDelayMessage: function(textMsg) {
var delayed = false;
if (textMsg.startsWith('window:') ||
textMsg.startsWith('canonicalidchange:') ||
textMsg.startsWith('celladdress:') ||
textMsg.startsWith('cellviewcursor:') ||
textMsg.startsWith('statechanged:') ||
textMsg.startsWith('invalidatecursor:') ||
textMsg.startsWith('viewinfo:')) {
//window.app.console.log('_tryToDelayMessage: textMsg: ' + textMsg);
var message = {msg: textMsg};
this._delayedMessages.push(message);
delayed = true;
}

if (delayed && !this._delayedMsgHandlerTimeoutId) {
_delayMessage: function(textMsg) {
var message = {msg: textMsg};
this._delayedMessages.push(message);

if (!this._delayedMsgHandlerTimeoutId) {
this._handleDelayedMessages();
}
return delayed;
},

_handleDelayedMessages: function() {
Expand Down

0 comments on commit 8ba14ab

Please sign in to comment.