loolwsd/ClientSession.cpp | 26 ++++++++++++++++++++++++-- loolwsd/ClientSession.hpp | 19 ++++++++++--------- loolwsd/LOOLWSD.cpp | 2 +- loolwsd/MasterProcessSession.cpp | 27 ++------------------------- loolwsd/MasterProcessSession.hpp | 8 +------- loolwsd/PrisonerSession.cpp | 10 ++++++++++ loolwsd/PrisonerSession.hpp | 14 ++++---------- 7 files changed, 52 insertions(+), 54 deletions(-)
New commits: commit 410123e2aa78a0c770175cffbdccf1300a28ec8f Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Mon May 16 21:03:45 2016 -0400 loolwsd: MasterProcessSession splitting: moved dispatchChild ... and PrisonerSession ctor Change-Id: I4c3707d71eb308ab739e5c264be1905453f9d719 Reviewed-on: https://gerrit.libreoffice.org/25047 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 721a253..a1a6dca 100644 --- a/loolwsd/ClientSession.cpp +++ b/loolwsd/ClientSession.cpp @@ -37,9 +37,11 @@ ClientSession::ClientSession(const std::string& id, std::shared_ptr<Poco::Net::WebSocket> ws, std::shared_ptr<DocumentBroker> docBroker, std::shared_ptr<BasicTileQueue> queue) : - MasterProcessSession(id, Kind::ToClient, ws, docBroker), + MasterProcessSession(id, Kind::ToClient, ws), + _docBroker(docBroker), _queue(queue), - _loadFailed(false) + _loadFailed(false), + _loadPart(-1) { Log::info("ClientSession ctor [" + getName() + "]."); } @@ -410,4 +412,24 @@ void ClientSession::sendCombinedTiles(const char* /*buffer*/, int /*length*/, St } } +void ClientSession::dispatchChild() +{ + std::ostringstream oss; + oss << "load"; + oss << " url=" << _docBroker->getPublicUri().toString(); + oss << " jail=" << _docBroker->getJailedUri().toString(); + + if (_loadPart >= 0) + oss << " part=" + std::to_string(_loadPart); + + if (_haveDocPassword) + oss << " password=" << _docPassword; + + if (!_docOptions.empty()) + oss << " options=" << _docOptions; + + const auto loadRequest = oss.str(); + forwardToPeer(loadRequest.c_str(), loadRequest.size()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp index dc9278b..976b9c6 100644 --- a/loolwsd/ClientSession.hpp +++ b/loolwsd/ClientSession.hpp @@ -64,6 +64,8 @@ public: _queue->put(message); } + std::shared_ptr<DocumentBroker> getDocumentBroker() const { return _docBroker; } + private: virtual bool _handleInput(const char *buffer, int length) override; @@ -78,8 +80,15 @@ private: void sendCombinedTiles(const char *buffer, int length, Poco::StringTokenizer& tokens); void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens); + void dispatchChild(); + private: + std::shared_ptr<DocumentBroker> _docBroker; + + /// The incoming message queue. + std::shared_ptr<BasicTileQueue> _queue; + // If this document holds the edit lock. // An edit lock will only allow the current session to make edits, // while other session opening the same document can only see @@ -89,23 +98,15 @@ private: /// Store URLs of completed 'save as' documents. MessageQueue _saveAsQueue; - /// The incoming message queue. - std::shared_ptr<BasicTileQueue> _queue; - /// Marks if document loading failed. bool _loadFailed; + int _loadPart; #if 0 - std::shared_ptr<DocumentBroker> getDocumentBroker() const { return _docBroker; } - bool shutdownPeer(Poco::UInt16 statusCode, const std::string& message); private: - void dispatchChild(); void forwardToPeer(const char *buffer, int length); - - int _loadPart; - std::shared_ptr<DocumentBroker> _docBroker; #endif }; diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 793f401..3e922b0 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -986,7 +986,7 @@ public: docBroker->load(jailId); auto ws = std::make_shared<WebSocket>(request, response); - auto session = std::make_shared<PrisonerSession>(sessionId, LOOLSession::Kind::ToPrisoner, ws, docBroker); + auto session = std::make_shared<PrisonerSession>(sessionId, ws, docBroker); // Connect the prison session to the client. docBroker->connectPeers(session); diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp index 888e2ae..84c7717 100644 --- a/loolwsd/MasterProcessSession.cpp +++ b/loolwsd/MasterProcessSession.cpp @@ -33,11 +33,8 @@ using Poco::StringTokenizer; MasterProcessSession::MasterProcessSession(const std::string& id, const Kind kind, - std::shared_ptr<Poco::Net::WebSocket> ws, - std::shared_ptr<DocumentBroker> docBroker) : - LOOLSession(id, kind, ws), - _loadPart(-1), - _docBroker(docBroker) + std::shared_ptr<Poco::Net::WebSocket> ws) : + LOOLSession(id, kind, ws) { Log::info("MasterProcessSession ctor [" + getName() + "]."); } @@ -46,26 +43,6 @@ MasterProcessSession::~MasterProcessSession() { } -void MasterProcessSession::dispatchChild() -{ - std::ostringstream oss; - oss << "load"; - oss << " url=" << _docBroker->getPublicUri().toString(); - oss << " jail=" << _docBroker->getJailedUri().toString(); - - if (_loadPart >= 0) - oss << " part=" + std::to_string(_loadPart); - - if (_haveDocPassword) - oss << " password=" << _docPassword; - - if (!_docOptions.empty()) - oss << " options=" << _docOptions; - - const auto loadRequest = oss.str(); - forwardToPeer(loadRequest.c_str(), loadRequest.size()); -} - void MasterProcessSession::forwardToPeer(const char *buffer, int length) { const auto message = getAbbreviatedMessage(buffer, length); diff --git a/loolwsd/MasterProcessSession.hpp b/loolwsd/MasterProcessSession.hpp index 9a59c21..bf860d9 100644 --- a/loolwsd/MasterProcessSession.hpp +++ b/loolwsd/MasterProcessSession.hpp @@ -24,12 +24,9 @@ class MasterProcessSession : public LOOLSession public: MasterProcessSession(const std::string& id, const Kind kind, - std::shared_ptr<Poco::Net::WebSocket> ws, - std::shared_ptr<DocumentBroker> docBroker); + std::shared_ptr<Poco::Net::WebSocket> ws); virtual ~MasterProcessSession(); - std::shared_ptr<DocumentBroker> getDocumentBroker() const { return _docBroker; } - bool shutdownPeer(Poco::UInt16 statusCode, const std::string& message); protected: @@ -44,9 +41,6 @@ class MasterProcessSession : public LOOLSession // obvious have to be rethought when we add collaboration and there can be several LOOL clients // per document being edited (i.e., per child process). std::weak_ptr<MasterProcessSession> _peer; - - int _loadPart; - std::shared_ptr<DocumentBroker> _docBroker; }; #endif diff --git a/loolwsd/PrisonerSession.cpp b/loolwsd/PrisonerSession.cpp index 8b658a9..30e0f23 100644 --- a/loolwsd/PrisonerSession.cpp +++ b/loolwsd/PrisonerSession.cpp @@ -33,6 +33,16 @@ using namespace LOOLProtocol; using Poco::Path; using Poco::StringTokenizer; +PrisonerSession::PrisonerSession(const std::string& id, + std::shared_ptr<Poco::Net::WebSocket> ws, + std::shared_ptr<DocumentBroker> docBroker) : + MasterProcessSession(id, Kind::ToPrisoner, ws), + _docBroker(docBroker), + _curPart(0) +{ + Log::info("ClientSession ctor [" + getName() + "]."); +} + PrisonerSession::~PrisonerSession() { Log::info("~PrisonerSession dtor [" + getName() + "]."); diff --git a/loolwsd/PrisonerSession.hpp b/loolwsd/PrisonerSession.hpp index 8d853b2..553d204 100644 --- a/loolwsd/PrisonerSession.hpp +++ b/loolwsd/PrisonerSession.hpp @@ -24,7 +24,9 @@ class ClientSession; class PrisonerSession final : public MasterProcessSession, public std::enable_shared_from_this<PrisonerSession> { public: - using MasterProcessSession::MasterProcessSession; + PrisonerSession(const std::string& id, + std::shared_ptr<Poco::Net::WebSocket> ws, + std::shared_ptr<DocumentBroker> docBroker); virtual ~PrisonerSession(); @@ -36,23 +38,15 @@ private: private: + std::shared_ptr<DocumentBroker> _docBroker; std::weak_ptr<ClientSession> _peer; int _curPart; #if 0 - std::shared_ptr<DocumentBroker> getDocumentBroker() const { return _docBroker; } - - std::shared_ptr<BasicTileQueue> getQueue() const { return _queue; } - bool shutdownPeer(Poco::UInt16 statusCode, const std::string& message); private: - void dispatchChild(); void forwardToPeer(const char *buffer, int length); - - int _loadPart; - std::shared_ptr<DocumentBroker> _docBroker; - std::shared_ptr<BasicTileQueue> _queue; #endif }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits