diff options
author | Henry Castro <hcastro@collabora.com> | 2020-03-12 23:29:39 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-03-19 08:56:09 +0100 |
commit | a09a0877d17ccee383403c4c4d6bd4427e6fcdde (patch) | |
tree | 795634869cb16378c1ecbae30573bf82916a7cf7 | |
parent | 1c4a66e736d73ab372745972a3bfcbb611e2de8a (diff) |
loleaflet: ensure forward message if early websocket is connected
This should never happen, since the _onMessage is re-assigned when
loadDocument is called, but it is better to ensure to forward all
messages.
Change-Id: I9a792bc077b26f2f92c30c4e7851c9d2b2637bfb
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90449
Tested-by: Andras Timar <andras.timar@collabora.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | loleaflet/js/global.js | 1 | ||||
-rw-r--r-- | loleaflet/src/core/Socket.js | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js index f98450fb0..a08c4cf3b 100644 --- a/loleaflet/js/global.js +++ b/loleaflet/js/global.js @@ -320,6 +320,7 @@ global.socket.onmessage = function (event) { if (typeof global.socket._onMessage === 'function') { + global.socket._emptyQueue(); global.socket._onMessage(event); } else { global.queueMsg.push(event.data); diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js index a173ef784..b4118479f 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -76,8 +76,11 @@ L.Socket = L.Class.extend({ } // process messages for early socket connection - if (socket && ((socket.readyState === 1 || socket.readyState === 0)) && - window.queueMsg && window.queueMsg.length > 0) { + this._emptyQueue(); + }, + + _emptyQueue: function () { + if (window.queueMsg && window.queueMsg.length > 0) { for (var it = 0; it < window.queueMsg.length; it++) { this._onMessage({data: window.queueMsg[it]}); } |