Conscience Core
TcpServer.h
Go to the documentation of this file.
1 
2 #ifndef TcpServer_H
3 #define TcpServer_H
4 
5 #include "CscCommon.h"
6 #include "TcpClient.h"
7 #include "AsioContext.h"
8 #include <mutex>
9 #include <thread>
10 #include <functional>
11 
12 using std::mutex, std::thread, std::function;
13 
15 
16  class TcpServerRuntimeError : public runtime_error {
17  public:
18  TcpServerRuntimeError(const string &message) : runtime_error(message.c_str()) {}
19  };
20 
21  class TcpServer {
22  public:
23  TcpServer(unsigned int port, function<void(TcpClient *communicationClient)> onConnection);
24  ~TcpServer();
25 
26 
27  private:
28  void waitClients();
29 
30  unique_ptr<CscLogger> logger = nullptr;
31  AsioContext *asioContext = nullptr;
32 
33  class Acceptor;
34  Acceptor *acceptor = nullptr;
35  function<void(TcpClient *communicationClient)> onConnection;
36 
37 
38  };
39 
40 }
41 #endif
conscience_core::communication::TcpServer::Acceptor
Definition: TcpServer.cpp:15
conscience_core::communication::AsioContext
Definition: AsioContext.h:20
conscience_core::communication::TcpServer
Definition: TcpServer.h:21
conscience_core::communication::TcpClient
Definition: TcpClient.h:17
AsioContext.h
conscience_core::communication::TcpServer::~TcpServer
~TcpServer()
Definition: TcpServer.cpp:46
conscience_core::communication::TcpServer::TcpServer
TcpServer(unsigned int port, function< void(TcpClient *communicationClient)> onConnection)
Definition: TcpServer.cpp:25
TcpClient.h
conscience_core::communication::TcpServerRuntimeError
Definition: TcpServer.h:16
nlohmann::detail::void
j template void())
Definition: json.hpp:4189
CscCommon.h
conscience_core::communication::TcpServerRuntimeError::TcpServerRuntimeError
TcpServerRuntimeError(const string &message)
Definition: TcpServer.h:18
conscience_core::communication
Definition: CscEntityClient.h:6