[Libreoffice-commits] online.git: loolwsd/DocumentBroker.cpp loolwsd/LOOLKit.cpp loolwsd/protocol.txt

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Oct 10 06:32:15 UTC 2016


 loolwsd/DocumentBroker.cpp |    4 ++++
 loolwsd/LOOLKit.cpp        |    7 +++++++
 loolwsd/protocol.txt       |   18 ++++++++++++++++++
 3 files changed, 29 insertions(+)

New commits:
commit 4fa7e53eaeb43233ac039525b58eb8c588968019
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Oct 9 16:37:13 2016 -0400

    loolwsd: unload child view when client disconnects
    
    Using a new internal command, when a client disconnects
    an internal 'disconnect' message is dispatched so
    the child process cleans up the ChildSession in question.
    
    Change-Id: I34166ad59e84ae389a3913bd2430fe537225bb4b
    Reviewed-on: https://gerrit.libreoffice.org/29650
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 02686fa..4e7e618 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -441,6 +441,10 @@ size_t DocumentBroker::removeSession(const std::string& id)
     if (it != _sessions.end())
     {
         _sessions.erase(it);
+
+        // Let the child know the client has disconnected.
+        const std::string msg("child-" + id + " disconnect");
+        _childProcess->getWebSocket()->sendFrame(msg.data(), msg.size());
     }
 
     return _sessions.size();
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 3bb689d..17f7f3f 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1264,6 +1264,13 @@ private:
             const auto it = _connections.find(viewId);
             if (it != _connections.end())
             {
+                if (message == "disconnect")
+                {
+                    Log::debug("Removing ChildSession " + value);
+                    _connections.erase(it);
+                    return true;
+                }
+
                 auto session = it->second->getSession();
                 if (session)
                 {
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index 418986d..d617354 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -373,6 +373,24 @@ saveas: url=<url>
     <url> is a URL of the destination, encoded. Sent from the child to the
     parent after a saveAs() completed.
 
+client-<sessionId> <Payload Message>
+
+    Forwarding message between a child and its parent session.
+    The payload message is forwarded to the ClientSession.
+
+parent -> child
+===============
+
+child-<sessionId> <Payload Message>
+
+    Forwarding message between a parent and its child session.
+    The payload message is forwarded to the ChildSession.
+
+disconnect
+
+    Signals to the child that the client for the respective connection
+    has disconnected.
+
 Admin console
 ===============
 


More information about the Libreoffice-commits mailing list