loolwsd/ChildSession.cpp | 55 ++++++++++++++--------------------------------- loolwsd/ChildSession.hpp | 2 - 2 files changed, 17 insertions(+), 40 deletions(-)
New commits: commit 006a49007c22773c3997a76316e0bc7699aa843a Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Mon Aug 15 19:06:42 2016 -0400 loolwsd: sync re-activating views by replaying state messages Change-Id: I0ce37ca75f10493a90107e93c253edf084a15f7f Reviewed-on: https://gerrit.libreoffice.org/28284 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp index ff4fed2..dd0d361 100644 --- a/loolwsd/ChildSession.cpp +++ b/loolwsd/ChildSession.cpp @@ -74,9 +74,16 @@ bool ChildSession::_handleInput(const char *buffer, int length) const std::string firstLine = getFirstLine(buffer, length); StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); + if (LOOLProtocol::tokenIndicatesUserInteraction(tokens[0])) + { + // Keep track of timestamps of incoming client messages that indicate user activity. + updateLastActivityTime(); + } + if (tokens.count() > 0 && tokens[0] == "useractive" && _loKitDocument != nullptr) { Log::debug("Handling message after inactivity of " + std::to_string(getInactivityMS()) + "ms."); + setIsActive(true); // Client is getting active again. // Send invalidation and other sync-up messages. @@ -99,44 +106,10 @@ bool ChildSession::_handleInput(const char *buffer, int length) //TODO: Is the order of these important? for (const auto& pair : _lastDocStates) { - switch (pair.first) - { - case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: - sendTextFrame("invalidatecursor: " + pair.second); - break; - case LOK_CALLBACK_TEXT_SELECTION: - sendTextFrame("textselection: " + pair.second); - break; - case LOK_CALLBACK_TEXT_SELECTION_START: - sendTextFrame("textselectionstart: " + pair.second); - break; - case LOK_CALLBACK_TEXT_SELECTION_END: - sendTextFrame("textselectionend: " + pair.second); - break; - case LOK_CALLBACK_CURSOR_VISIBLE: - sendTextFrame("cursorvisible: " + pair.second); - break; - case LOK_CALLBACK_GRAPHIC_SELECTION: - sendTextFrame("graphicselection: " + pair.second); - break; - case LOK_CALLBACK_CELL_CURSOR: - sendTextFrame("cellcursor: " + pair.second); - break; - case LOK_CALLBACK_CELL_FORMULA: - sendTextFrame("cellformula: " + pair.second); - break; - case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: - getStatus("", 0); - getPartPageRectangles("", 0); - break; - } + loKitCallback(pair.first, pair.second); } - } - if (LOOLProtocol::tokenIndicatesUserInteraction(tokens[0])) - { - // Keep track of timestamps of incoming client messages that indicate user activity. - updateLastActivityTime(); + Log::debug("Finished replaying messages."); } if (tokens[0] == "dummymsg") @@ -920,9 +893,15 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload) nType == LOK_CALLBACK_TEXT_SELECTION || nType == LOK_CALLBACK_TEXT_SELECTION_START || nType == LOK_CALLBACK_TEXT_SELECTION_END || - nType == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED) + nType == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED || + nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR || + nType == LOK_CALLBACK_TEXT_VIEW_SELECTION || + nType == LOK_CALLBACK_CELL_VIEW_CURSOR || + nType == LOK_CALLBACK_GRAPHIC_VIEW_SELECTION || + nType == LOK_CALLBACK_VIEW_CURSOR_VISIBLE || + nType == LOK_CALLBACK_VIEW_LOCK) { - setDocState(nType, rPayload); + _lastDocStates[nType] = rPayload; } const auto typeName = LOKitHelper::kitCallbackTypeToString(nType); diff --git a/loolwsd/ChildSession.hpp b/loolwsd/ChildSession.hpp index d2ffa01..61cac9d 100644 --- a/loolwsd/ChildSession.hpp +++ b/loolwsd/ChildSession.hpp @@ -65,8 +65,6 @@ public: unsigned getViewId() const { return _viewId; } int getPart() const { return _loKitDocument->getPart(); } - void setDocState(const int type, const std::string& payload) { _lastDocStates[type] = payload; } - void loKitCallback(const int nType, const std::string& rPayload); static std::unique_lock<std::recursive_mutex> getLock() { return std::unique_lock<std::recursive_mutex>(Mutex); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits