loolwsd/ChildSession.cpp | 74 +++++++++++++++++++++++++++++------------------ loolwsd/ChildSession.hpp | 3 + 2 files changed, 48 insertions(+), 29 deletions(-)
New commits: commit e08503e2757700a7b566d9fc8c8b300b4af78fee Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Tue Nov 1 09:24:14 2016 -0400 loolwsd: save and replay doc state changes Document state changes come in with the same event ID. We need to store them in a separate map (also renamed the old 'states' map to 'events'). All important events are now replayed correctly and traced. Change-Id: I52346b0d252730ba5cedb091b14898479c2a52c5 Reviewed-on: https://gerrit.libreoffice.org/30466 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 3606439..ede393e 100644 --- a/loolwsd/ChildSession.cpp +++ b/loolwsd/ChildSession.cpp @@ -111,11 +111,19 @@ bool ChildSession::_handleInput(const char *buffer, int length) sendTextFrame("setpart: part=" + std::to_string(curPart)); //TODO: Is the order of these important? - for (const auto& pair : _lastDocStates) + for (const auto& pair : _lastDocEvents) { + const auto typeName = LOKitHelper::kitCallbackTypeToString(pair.first); + LOG_TRC("Replaying missed event: " << typeName << ": " << pair.second); loKitCallback(pair.first, pair.second); } + for (const auto& pair : _lastDocStates) + { + LOG_TRC("Replaying missed state-change: STATE_CHANED: " << pair.second); + loKitCallback(LOK_CALLBACK_STATE_CHANGED, pair.second); + } + Log::debug("Finished replaying messages."); } @@ -938,6 +946,8 @@ bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, StringTokeniz void ChildSession::loKitCallback(const int nType, const std::string& rPayload) { const auto typeName = LOKitHelper::kitCallbackTypeToString(nType); + Log::trace() << "CallbackWorker::callback [" << getName() << "]: " + << typeName << " [" << rPayload << "]." << Log::end; if (isCloseFrame()) { @@ -951,6 +961,41 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload) } else if (!isActive()) { + // Cache important notifications to replay them when our client + // goes inactive and loses them. + if (nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || + nType == LOK_CALLBACK_CURSOR_VISIBLE || + nType == LOK_CALLBACK_CELL_CURSOR || + nType == LOK_CALLBACK_CELL_FORMULA || + nType == LOK_CALLBACK_GRAPHIC_SELECTION || + 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_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) + { + auto lock(getLock()); + + _lastDocEvents[nType] = rPayload; + } + + if (nType == LOK_CALLBACK_STATE_CHANGED) + { + std::string name; + std::string value; + if (LOOLProtocol::parseNameValuePair(rPayload, name, value, '=')) + { + auto lock(getLock()); + + _lastDocStates[name] = rPayload; + } + } + // Pass save notifications through. if (nType != LOK_CALLBACK_UNO_COMMAND_RESULT || rPayload.find(".uno:Save") == std::string::npos) { @@ -959,33 +1004,6 @@ void ChildSession::loKitCallback(const int nType, const std::string& rPayload) } } - Log::trace() << "CallbackWorker::callback [" << getName() << "]: " - << typeName << " [" << rPayload << "]." << Log::end; - - // Cache important notifications to replay them when our client - // goes inactive and loses them. - if (nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || - nType == LOK_CALLBACK_CURSOR_VISIBLE || - nType == LOK_CALLBACK_CELL_CURSOR || - nType == LOK_CALLBACK_CELL_FORMULA || - nType == LOK_CALLBACK_GRAPHIC_SELECTION || - 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_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 || - nType == LOK_CALLBACK_STATE_CHANGED) - { - auto lock(getLock()); - - _lastDocStates[nType] = rPayload; - } - switch (nType) { case LOK_CALLBACK_INVALIDATE_TILES: diff --git a/loolwsd/ChildSession.hpp b/loolwsd/ChildSession.hpp index 4730f72..624090c 100644 --- a/loolwsd/ChildSession.hpp +++ b/loolwsd/ChildSession.hpp @@ -127,7 +127,8 @@ private: std::shared_ptr<lok::Document> _loKitDocument; std::string _docType; - std::map<int, std::string> _lastDocStates; + std::map<std::string, std::string> _lastDocStates; + std::map<int, std::string> _lastDocEvents; /// Synchronize _loKitDocument access. /// This should be owned by Document. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits