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

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


 loolwsd/LOOLKit.cpp |   35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

New commits:
commit 3963382913cd5463f720995fb76af0435eeedf49
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Oct 8 13:34:53 2016 -0400

    loolwsd: forward child messages to the respective ChildSession
    
    Change-Id: Ib1e0c51effd046a2f0d0e5708c501b6414caa81a
    Reviewed-on: https://gerrit.libreoffice.org/29635
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 575b947..a2fbf97 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1225,6 +1225,35 @@ private:
         return _loKitDocument;
     }
 
+    bool forwardToChild(const std::string& prefix, const std::vector<char>& payload)
+    {
+        const std::string message(payload.data() + prefix.size(), payload.size() - prefix.size());
+        Log::trace("Forwarding payload to client: " + message);
+
+        std::string name;
+        int viewId = -1;
+        if (LOOLProtocol::parseNameIntegerPair(prefix, name, viewId, '-') && name == "child")
+        {
+            const auto it = _connections.find(viewId);
+            if (it != _connections.end() && it->second->isRunning())
+            {
+                auto session = it->second->getSession();
+                if (session && session->getViewId() == viewId)
+                {
+                    return session->handleInput(message.data(), message.size());
+                }
+            }
+
+            Log::warn() << "Child session [" << viewId << "] not found to forward message: " << message << Log::end;
+        }
+        else
+        {
+            Log::error("Failed to parse prefix of forward-to-child message: " + message);
+        }
+
+        return false;
+    }
+
     void run() override
     {
         Util::setThreadName("lok_handler");
@@ -1235,7 +1264,7 @@ private:
         {
             while (!_stop && !TerminationFlag)
             {
-                const auto input = _tileQueue->get();
+                const TileQueue::Payload input = _tileQueue->get();
                 if (_stop || TerminationFlag)
                 {
                     break;
@@ -1258,6 +1287,10 @@ private:
                 {
                     renderCombinedTiles(tokens, _ws);
                 }
+                else if (LOOLProtocol::getFirstToken(tokens[0], '-') == "child")
+                {
+                    forwardToChild(tokens[0], input);
+                }
                 else if (tokens[0] == "callback")
                 {
                     int viewId = std::stoi(tokens[1]); // -1 means broadcast


More information about the Libreoffice-commits mailing list