loolwsd/ChildProcessSession.cpp | 8 ++++++-- loolwsd/LOOLProtocol.hpp | 11 +++++++++-- loolwsd/MasterProcessSession.cpp | 10 +++++++--- 3 files changed, 22 insertions(+), 7 deletions(-)
New commits: commit 8c1e5057fd475596a80e1184b50c923d974bf4ce Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Apr 9 23:16:09 2016 -0400 loolwsd: last activity time updates ignores non-interactive commands Change-Id: I763c2945f6acb30bea9d04d91982e9fb0c8ca6ca Reviewed-on: https://gerrit.libreoffice.org/23950 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp index 62d64ab..912955e 100644 --- a/loolwsd/ChildProcessSession.cpp +++ b/loolwsd/ChildProcessSession.cpp @@ -333,11 +333,15 @@ bool ChildProcessSession::_handleInput(const char *buffer, int length) //TODO: Sync cursor. } - updateLastActivityTime(); - 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[0] == "dummymsg") { // Just to update the activity of view-only mode diff --git a/loolwsd/LOOLProtocol.hpp b/loolwsd/LOOLProtocol.hpp index f482041..0e7a541 100644 --- a/loolwsd/LOOLProtocol.hpp +++ b/loolwsd/LOOLProtocol.hpp @@ -63,11 +63,18 @@ namespace LOOLProtocol return getFirstToken(message.data(), message.size()); } + /// Returns true if the token is a user-interaction token. + /// Currently this excludes commands sent automatically. + /// Notice that this doesn't guarantee editing activity, + /// rather just user interaction with the UI. inline bool tokenIndicatesUserInteraction(const std::string& token) { - return (token != "tile" && - token != "status"); + // Exclude tokens that include these keywords, + // such as canceltiles statusindicator. + return (token.find("tile") == std::string::npos && + token.find("status") == std::string::npos && + token.find("state") == std::string::npos); } /// Returns the first line of a message. diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp index 4fc5ecf..f9ad626 100644 --- a/loolwsd/MasterProcessSession.cpp +++ b/loolwsd/MasterProcessSession.cpp @@ -103,12 +103,16 @@ bool MasterProcessSession::handleDisconnect(Poco::StringTokenizer& tokens) bool MasterProcessSession::_handleInput(const char *buffer, int length) { - updateLastActivityTime(); - const std::string firstLine = getFirstLine(buffer, length); StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); Log::trace(getName() + ": handling [" + firstLine + "]."); + if (LOOLProtocol::tokenIndicatesUserInteraction(tokens[0])) + { + // Keep track of timestamps of incoming client messages that indicate user activity. + updateLastActivityTime(); + } + if (tokens[0] == "loolclient") { const auto versionTuple = ParseVersion(tokens[1]); @@ -141,7 +145,7 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length) if (tokens[0] == "unocommandresult:") { const std::string stringMsg(buffer, length); - Log::info(getName() +"Command: " + stringMsg); + Log::info(getName() + "Command: " + stringMsg); const auto index = stringMsg.find_first_of("{"); if (index != std::string::npos) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits