loolwsd/ClientSession.cpp  |    5 +++++
 loolwsd/ClientSession.hpp  |    2 ++
 loolwsd/DocumentBroker.cpp |   18 ++++++++++++++++++
 loolwsd/DocumentBroker.hpp |    3 +++
 4 files changed, 28 insertions(+)

New commits:
commit 6cf9cdf032bde81d9d27c1dc0e3c140442453009
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sat Oct 8 14:25:27 2016 -0400

    loolwsd: forward to child
    
    Change-Id: I308963a78fb05e85bcb2e6c257640b56583859b5
    Reviewed-on: https://gerrit.libreoffice.org/29636
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/loolwsd/ClientSession.cpp b/loolwsd/ClientSession.cpp
index 9884178..c4cfcdf 100644
--- a/loolwsd/ClientSession.cpp
+++ b/loolwsd/ClientSession.cpp
@@ -358,4 +358,9 @@ bool ClientSession::shutdownPeer(Poco::UInt16 statusCode, 
const std::string& mes
     return peer != nullptr;
 }
 
+bool ClientSession::forwardToChild(const char *buffer, int length)
+{
+    return _docBroker->forwardToChild(getId(), buffer, length);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index 237fe13..7508802 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -72,6 +72,8 @@ private:
     bool sendCombinedTiles(const char *buffer, int length, 
Poco::StringTokenizer& tokens);
     bool sendFontRendering(const char *buffer, int length, 
Poco::StringTokenizer& tokens);
 
+    bool forwardToChild(const char *buffer, int length);
+
 private:
 
     std::shared_ptr<DocumentBroker> _docBroker;
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index e8bab09..e2e5423 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -722,6 +722,24 @@ void DocumentBroker::setModified(const bool value)
     _isModified = value;
 }
 
+bool DocumentBroker::forwardToChild(const std::string& viewId, const char 
*buffer, int length)
+{
+    const auto message = std::string(buffer, length);
+    Log::trace() << "Forwarding payload to child [" << viewId << "]: " << 
message << Log::end;
+
+    const auto it = _sessions.find(viewId);
+    if (it != _sessions.end())
+    {
+        return it->second->sendTextFrame("child-" + viewId + ' ' + message);
+    }
+    else
+    {
+        Log::warn() << "Client session [" << viewId << "] not found to forward 
message: " << message << Log::end;
+    }
+
+    return false;
+}
+
 bool DocumentBroker::forwardToClient(const std::string& prefix, const 
std::vector<char>& payload)
 {
     const std::string message(payload.data() + prefix.size(), payload.size() - 
prefix.size());
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 80e93b2..bd0f7f3 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -230,6 +230,9 @@ public:
 
     bool handleInput(const std::vector<char>& payload);
 
+    /// Forward a message from client session to its respective child session.
+    bool forwardToChild(const std::string& viewId, const char *buffer, int 
length);
+
 private:
 
     /// Sends the .uno:Save command to LoKit.
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to