[Libreoffice-commits] online.git: loolwsd/DocumentBroker.cpp loolwsd/LOOLKit.cpp loolwsd/TileCache.cpp loolwsd/TileCache.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Thu May 5 14:23:40 UTC 2016
loolwsd/DocumentBroker.cpp | 10 +++++++++-
loolwsd/LOOLKit.cpp | 1 +
loolwsd/TileCache.cpp | 24 +++++++++++++++---------
loolwsd/TileCache.hpp | 2 +-
4 files changed, 26 insertions(+), 11 deletions(-)
New commits:
commit 1643938a8e2e3f0c28280abb848bb072649607a3
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Thu May 5 10:19:13 2016 -0400
loolwsd: support the tile id param when broadcasting tiles to subscribers
Obviously this is dangerous, since the id is not part of the
subscription key (the filename) so different clients could
have different ids on the same part, but in practice I
expect this not to happen. Though that clearly depends on
how clients use the id.
Change-Id: I52a0b043c9b5e5ad1111b692e4216cc9ffec5b2b
Reviewed-on: https://gerrit.libreoffice.org/24680
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 9785b94..d6e686a 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -473,13 +473,21 @@ void DocumentBroker::handleTileResponse(const std::vector<char>& payload)
!getTokenInteger(tokens[7], "tileheight", tileHeight))
assert(false);
+ size_t index = 8;
+ int id = -1;
+ if (tokens.count() > index && tokens[index].find("id") == 0)
+ {
+ getTokenInteger(tokens[index], "id", id);
+ ++index;
+ }
+
const auto buffer = payload.data();
const auto length = payload.size();
if(firstLine.size() < static_cast<std::string::size_type>(length) - 1)
{
tileCache().saveTile(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight, buffer + firstLine.size() + 1, length - firstLine.size() - 1);
- tileCache().notifyAndRemoveSubscribers(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight);
+ tileCache().notifyAndRemoveSubscribers(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight, id);
}
else
{
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 4a65094..cebb4c9 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -632,6 +632,7 @@ public:
//if (_multiView)
//_loKitDocument->pClass->setView(_loKitDocument, _viewId);
+ // Send back the request with all optional parameters given in the request.
std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end() - 1);
#if ENABLE_DEBUG
diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp
index 3242344..961e7bd 100644
--- a/loolwsd/TileCache.cpp
+++ b/loolwsd/TileCache.cpp
@@ -330,7 +330,7 @@ void TileCache::saveLastModified(const Timestamp& timestamp)
modTimeFile.close();
}
-void TileCache::notifyAndRemoveSubscribers(int part, int width, int height, int tilePosX, int tilePosY, int tileWidth, int tileHeight)
+void TileCache::notifyAndRemoveSubscribers(int part, int width, int height, int tilePosX, int tilePosY, int tileWidth, int tileHeight, int id)
{
std::unique_lock<std::mutex> lock(_tilesBeingRenderedMutex);
@@ -338,14 +338,20 @@ void TileCache::notifyAndRemoveSubscribers(int part, int width, int height, int
if (!tileBeingRendered)
return;
- const std::string message("tile "
- " part=" + std::to_string(part) +
- " width=" + std::to_string(width) +
- " height=" + std::to_string(height) +
- " tileposx=" + std::to_string(tilePosX) +
- " tileposy=" + std::to_string(tilePosY) +
- " tilewidth=" + std::to_string(tileWidth) +
- " tileheight=" + std::to_string(tileHeight));
+ std::ostringstream oss;
+ oss << "tile part=" << part
+ << " width=" << width
+ << " height=" << height
+ << " tileposx=" << tilePosX
+ << " tileposy=" << tilePosY
+ << " tilewidth=" << tileWidth
+ << " tileheight=" << tileHeight;
+ if (id >= 0)
+ {
+ oss << " id=" << id;
+ }
+
+ const std::string message = oss.str();
Log::debug("Sending tile message to subscribers: " + message);
for (const auto& i: tileBeingRendered->_subscribers)
diff --git a/loolwsd/TileCache.hpp b/loolwsd/TileCache.hpp
index 6df3b39..270d679 100644
--- a/loolwsd/TileCache.hpp
+++ b/loolwsd/TileCache.hpp
@@ -45,7 +45,7 @@ public:
void saveTile(int part, int width, int height, int tilePosX, int tilePosY, int tileWidth, int tileHeight, const char *data, size_t size);
- void notifyAndRemoveSubscribers(int part, int width, int height, int tilePosX, int tilePosY, int tileWidth, int tileHeight);
+ void notifyAndRemoveSubscribers(int part, int width, int height, int tilePosX, int tilePosY, int tileWidth, int tileHeight, int id);
std::string getTextFile(const std::string& fileName);
More information about the Libreoffice-commits
mailing list