blob: 818fcfe9b666e6aa29fe1c84d93d4a4fd6bb768d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#pragma once
#include <filesystem>
#include <memory>
#include <mutex>
#include <string>
#include <boost/asio/ip/tcp.hpp>
#include "config.h"
#include "connectionregistry.h"
#include "storage.h"
class Whiteboard
{
public:
Whiteboard();
int run(int argc, char* argv[]);
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;
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_file(connection& c, const std::string& id); // notify all other id-related connections about changes
void notify_other_connections_pos(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();
};
|