1 #ifndef GRAIL_TCPSERVER_H
2 #define GRAIL_TCPSERVER_H
4 #include "../../../libs/poco/Net/include/Poco/Net/SocketAddress.h"
5 #include "../../../libs/poco/Net/include/Poco/Net/StreamSocket.h"
6 #include "../../../libs/poco/Net/include/Poco/Net/SocketStream.h"
7 #include "../../../libs/poco/Net/include/Poco/Net/TCPServer.h"
24 void SendToAll(
const std::string& data);
26 void AddEventOnConnection(std::function<
void()> event);
28 bool IsAnyConnected()
const;
31 void AcceptConnections();
32 void CheckDisconnects();
34 constexpr
static const Poco::Int32 MAGIC = 0x22669977;
35 const std::string STREAM_MAGIC;
38 std::atomic<bool> isWorking{
true};
40 std::unique_ptr<Poco::Net::ServerSocket> server;
41 std::unique_ptr<std::thread> connectionAcceptorThread =
nullptr;
42 std::unique_ptr<std::thread> disconnectCheckerThread =
nullptr;
43 std::vector<Poco::Net::StreamSocket> clients{};
44 std::vector<std::function<void()>> onClientConnected{};
46 mutable std::mutex clientsMutex{};
47 std::mutex eventMutex{};
Definition: TCPServer.h:18