loleaflet/src/core/Log.js    |    1 +
 loleaflet/src/core/Socket.js |   20 ++++++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit bd005c701d62ecf30c6f440fe54ac801c5ae3dd4
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sat Apr 23 14:01:01 2016 -0400

    loleaflet: support for logging socket.send
    
    Change-Id: I13ea5c6df6cdcda7d9cbb256de6cd4a34757a244
    Reviewed-on: https://gerrit.libreoffice.org/24321
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/loleaflet/src/core/Log.js b/loleaflet/src/core/Log.js
index 667378b..7f0fb03 100644
--- a/loleaflet/src/core/Log.js
+++ b/loleaflet/src/core/Log.js
@@ -13,6 +13,7 @@ L.Log = {
                msg = msg.replace(/(\r\n|\n|\r)/gm, ' ');
                this._logs.push({msg : msg, direction : direction,
                        coords : tileCoords, time : time});
+               //console.log(time + '-' + direction + ': ' + msg);
        },
 
        _getEntries: function () {
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index d2ce2ec..45da3d6 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -62,10 +62,19 @@ L.Socket = L.Class.extend({
                }
        },
 
+    _doSend: function(msg, coords) {
+        // Only attempt to log text frames, not binary ones.
+        if (typeof msg === 'string') {
+            L.Log.log(msg, L.OUTGOING, coords);
+        }
+
+        this.socket.send(msg);
+    },
+
        _onOpen: function () {
                // Always send the protocol version number.
                // TODO: Move the version number somewhere sensible.
-               this.socket.send('loolclient ' + this.ProtocolVersionNumber);
+               this._doSend('loolclient ' + this.ProtocolVersionNumber);
 
                var msg = 'load url=' + this._map.options.doc;
                if (this._map._docLayer) {
@@ -85,12 +94,11 @@ L.Socket = L.Class.extend({
                        };
                        msg += ' options=' + JSON.stringify(options);
                }
-               this.socket.send(msg);
-               this.socket.send('status');
-               this.socket.send('partpagerectangles');
+               this._doSend(msg);
+               this._doSend('status');
+               this._doSend('partpagerectangles');
                for (var i = 0; i < this._msgQueue.length; i++) {
-                       this.socket.send(this._msgQueue[i].msg);
-                       L.Log.log(this._msgQueue[i].msg, 
this._msgQueue[i].coords);
+                       this._doSend(this._msgQueue[i].msg, 
this._msgQueue[i].coords);
                }
                this._msgQueue = [];
        },
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to