Skip to content

Commit

Permalink
When document layer is not ready and socket message is not delayed, m…
Browse files Browse the repository at this point in the history
…essage is lost.

Wait for doclayer to be ready in this case.

Signed-off-by: Gökay Şatır <gokaysatir@gmail.com>
Change-Id: Ib3e9427a89e8be7d97f7baf92bdcb6295c695ca2
  • Loading branch information
gokaysatir committed Aug 14, 2023
1 parent 8570a03 commit e660bb8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions browser/src/core/Socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,20 @@ app.definitions.Socket = L.Class.extend({
if (this._map._docLayer && !msgDelayed) {
this._map._docLayer._onMessage(textMsg, e.image);
}
else if (!this._map._docLayer && !msgDelayed) {
// If message is delayed and document layer is not ready at the time, message gets lost.
// To prevent this, we wait a little for document layer.
var waitForDocLayer = function(message, image) {
setTimeout(function() {
if (this._map._docLayer)
this._map._docLayer._onMessage(message, image);
else
waitForDocLayer(message, image);
}.bind(this), 300);
}.bind(this);

waitForDocLayer(textMsg, e.image);
}
},

_exportAsCallback: function(command) {
Expand Down

0 comments on commit e660bb8

Please sign in to comment.