summaryrefslogtreecommitdiffhomepage
path: root/whiteboard.h
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-26 20:46:30 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-26 20:46:30 +0100
commit789e5555ab4c44a1ae779eccf6ccf8340602cf22 (patch)
treefd1c15ac38ec4d43965d8e12a149ae52a0808a73 /whiteboard.h
parent004db5e7e4e9ab6ac5b4730873c6b8f58da92930 (diff)
Websockets: Notify other clients of changes
Diffstat (limited to 'whiteboard.h')
-rw-r--r--whiteboard.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/whiteboard.h b/whiteboard.h
index d645115..e39b94e 100644
--- a/whiteboard.h
+++ b/whiteboard.h
@@ -8,6 +8,7 @@
#include <boost/asio/ip/tcp.hpp>
#include "config.h"
+#include "connectionregistry.h"
#include "storage.h"
class Whiteboard
@@ -20,8 +21,13 @@ private:
std::unique_ptr<Config> m_config;
std::unique_ptr<Storage> m_storage;
std::mutex m_storage_mutex;
+ std::mutex m_websocket_mutex;
+
+ ConnectionRegistry m_registry;
- std::string handle_request(const std::string& request);
+ using connection = std::shared_ptr<boost::beast::websocket::stream<boost::asio::ip::tcp::socket>>;
+ std::string handle_request(connection& c, const std::string& request);
+ void notify_other_connections(connection& c, const std::string& id); // notify all other id-related connections about changes
void do_session(boost::asio::ip::tcp::socket socket);
void storage_cleanup();
};