summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2016-08-25 23:28:42 +0530
committerAshod Nakashian <ashnakash@gmail.com>2016-08-25 18:26:31 +0000
commit178808f9893ce51d1906bfd1ff7e19da8920c823 (patch)
tree3ff5e8e6bd9626c0281c21f833bd9bdfb8d807ce
parentloolwsd: Send viewId to clients, not sessionId (diff)
downloadonline-178808f9893ce51d1906bfd1ff7e19da8920c823.tar.gz
online-178808f9893ce51d1906bfd1ff7e19da8920c823.zip
loolwsd: Notify other views when new view is added
... but no need to notify the one which is just added. Earlier behavior was notifying only the one which is just added, which is redundant as same is accomplished by 'status' message. Change-Id: Ib09424d186c49527b7b9c36fdabf90c31518ee04 Reviewed-on: https://gerrit.libreoffice.org/28395 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--loolwsd/ChildSession.cpp2
-rw-r--r--loolwsd/ChildSession.hpp4
-rw-r--r--loolwsd/LOOLKit.cpp17
3 files changed, 22 insertions, 1 deletions
diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp
index a0bb2275c9..4f0d91eb07 100644
--- a/loolwsd/ChildSession.cpp
+++ b/loolwsd/ChildSession.cpp
@@ -327,7 +327,7 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT
_viewId = _loKitDocument->getView();
const auto viewId = std::to_string(_viewId);
Log::info("Created new view: " + viewId);
- sendTextFrame("addview: " + viewId);
+ _docManager.notifyOtherSessions(getId(), "addview: " + viewId);
}
_docType = LOKitHelper::getDocumentTypeAsString(_loKitDocument->get());
diff --git a/loolwsd/ChildSession.hpp b/loolwsd/ChildSession.hpp
index ddb804f535..7bd51220ab 100644
--- a/loolwsd/ChildSession.hpp
+++ b/loolwsd/ChildSession.hpp
@@ -42,6 +42,10 @@ public:
/// Get a list of all current view IDs.
virtual
std::vector<unsigned> getViewIds() const = 0;
+
+ /// Send message to all other sessions except 'sessionId'
+ virtual
+ void notifyOtherSessions(const std::string& sessionId, const std::string& message) const = 0;
};
/// Represents a client session, with the socket end-point,
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index b73779eb09..03168357d5 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -942,6 +942,23 @@ private:
return v;
}
+ void notifyOtherSessions(const std::string& sessionId, const std::string& message) const override
+ {
+ std::unique_lock<std::mutex> lock(_mutex);
+
+ for (auto& it: _connections)
+ {
+ if (it.second->isRunning() && it.second->getSessionId() != sessionId)
+ {
+ auto session = it.second->getSession();
+ if (session)
+ {
+ session->sendTextFrame(message);
+ }
+ }
+ }
+ }
+
private:
std::shared_ptr<lok::Document> load(const std::string& sessionId,