loleaflet: don't communicate with WSD when inactive to avoid confusing it
Change-Id: I4c7f252264fba4a46c6be9e9592a2aec165813bd Reviewed-on: https://gerrit.libreoffice.org/24289 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
parent
3a4c02b71d
commit
9e64efe78b
1 changed files with 13 additions and 0 deletions
|
@ -8,6 +8,7 @@ L.Socket = L.Class.extend({
|
|||
|
||||
initialize: function (map) {
|
||||
this._map = map;
|
||||
this._active = true;
|
||||
try {
|
||||
this.socket = new WebSocket(map.options.server + '/' + map.options.doc);
|
||||
} catch (e) {
|
||||
|
@ -30,6 +31,18 @@ L.Socket = L.Class.extend({
|
|||
},
|
||||
|
||||
sendMessage: function (msg, coords) {
|
||||
if (!msg.startsWith('useractive') && !msg.startsWith('userinactive') && !this._active) {
|
||||
// Avoid communicating when we're inactive.
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.startsWith('useractive')) {
|
||||
this._active = true;
|
||||
}
|
||||
else if (msg.startsWith('userinactive')) {
|
||||
this._active = false;
|
||||
}
|
||||
|
||||
var socketState = this.socket.readyState;
|
||||
if (socketState === 2 || socketState === 3) {
|
||||
this.initialize(this._map);
|
||||
|
|
Loading…
Reference in a new issue