[Libreoffice-commits] online.git: wsd/PrisonerSession.cpp wsd/PrisonerSession.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Jan 23 05:53:40 UTC 2017
wsd/PrisonerSession.cpp | 32 +++++++++++++++++++-------------
wsd/PrisonerSession.hpp | 2 +-
2 files changed, 20 insertions(+), 14 deletions(-)
New commits:
commit 8c34244285731fa7554479694aed0beaaca2ac6e
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Jan 21 20:13:09 2017 -0500
wsd: forwardToPeer now takes pre-constructed Message
Change-Id: I58acbeb6d27fbc9b99434c2743f69a4faa3a048b
Reviewed-on: https://gerrit.libreoffice.org/33430
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/wsd/PrisonerSession.cpp b/wsd/PrisonerSession.cpp
index 55db938..d05a9a6 100644
--- a/wsd/PrisonerSession.cpp
+++ b/wsd/PrisonerSession.cpp
@@ -108,7 +108,10 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
errorKind == "passwordrequired:to-modify" ||
errorKind == "wrongpassword")
{
- forwardToPeer(peer, buffer, length, false);
+ const auto payload = std::make_shared<Message>(buffer, length,
+ Message::Dir::Out,
+ Message::Type::Text);
+ forwardToPeer(peer, payload);
LOG_WRN("Document load failed: " << errorKind);
return false;
}
@@ -175,7 +178,10 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
_docBroker->setLoaded();
// Forward the status response to the client.
- return forwardToPeer(peer, buffer, length, false);
+ const auto payload = std::make_shared<Message>(buffer, length,
+ Message::Dir::Out,
+ Message::Type::Text);
+ return forwardToPeer(peer, payload);
}
else if (tokens[0] == "commandvalues:")
{
@@ -242,8 +248,10 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
getTokenString(tokens[2], "char", text);
assert(firstLine.size() < static_cast<std::string::size_type>(length));
_docBroker->tileCache().saveRendering(font+text, "font", buffer + firstLine.size() + 1, length - firstLine.size() - 1);
- forwardToPeer(peer, buffer, length, true);
- return true;
+ const auto payload = std::make_shared<Message>(buffer, length,
+ Message::Dir::Out,
+ Message::Type::Binary);
+ return forwardToPeer(peer, payload);
}
}
else
@@ -257,14 +265,17 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
const bool isBinary = buffer[length - 1] != '}' && firstLine.find('{') == std::string::npos;
// Forward everything else.
- forwardToPeer(peer, buffer, length, isBinary);
- return true;
+ const auto payload = std::make_shared<Message>(buffer, length,
+ Message::Dir::Out,
+ isBinary ? Message::Type::Binary
+ : Message::Type::Text);
+ return forwardToPeer(peer, payload);
}
bool PrisonerSession::forwardToPeer(const std::shared_ptr<ClientSession>& clientSession,
- const char* buffer, int length, const bool binary)
+ const std::shared_ptr<Message>& payload)
{
- const auto message = LOOLProtocol::getAbbreviatedMessage(buffer, length);
+ const auto& message = payload->abbr();
if (clientSession->isCloseFrame())
{
@@ -280,11 +291,6 @@ bool PrisonerSession::forwardToPeer(const std::shared_ptr<ClientSession>& client
}
LOG_TRC(getName() << " -> " << clientSession->getName() << ": " << message);
-
- auto payload = std::make_shared<Message>(buffer, length,
- Message::Dir::Out,
- binary ? Message::Type::Binary
- : Message::Type::Text);
clientSession->enqueueSendMessage(payload);
return true;
diff --git a/wsd/PrisonerSession.hpp b/wsd/PrisonerSession.hpp
index 5a333a2..12d607c 100644
--- a/wsd/PrisonerSession.hpp
+++ b/wsd/PrisonerSession.hpp
@@ -35,7 +35,7 @@ private:
virtual bool _handleInput(const char* buffer, int length) override;
bool forwardToPeer(const std::shared_ptr<ClientSession>& clientSession,
- const char* buffer, int length, const bool binary);
+ const std::shared_ptr<Message>& payload);
private:
std::shared_ptr<DocumentBroker> _docBroker;
More information about the Libreoffice-commits
mailing list