loleaflet/src/core/Socket.js |   13 +++++++++++++
 1 file changed, 13 insertions(+)

New commits:
commit 9e64efe78bb85af5176d6b655acfdd6349c064bb
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Fri Apr 22 00:30:15 2016 -0400

    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 <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 3b6ad4b..b8886d3 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -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);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to