loolwsd: last activity time updates ignores non-interactive commands

Change-Id: I763c2945f6acb30bea9d04d91982e9fb0c8ca6ca
Reviewed-on: https://gerrit.libreoffice.org/23950
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2016-04-09 23:16:09 -04:00 committed by Ashod Nakashian
parent 213888c45c
commit 8c1e5057fd
3 changed files with 22 additions and 7 deletions

View file

@ -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

View file

@ -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.

View file

@ -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)
{