Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
GcTcpHub.hxx
Go to the documentation of this file.
1
34#ifndef _UTILS_GCTCPHUB_HXX_
35#define _UTILS_GCTCPHUB_HXX_
36
38#include "utils/Hub.hxx"
39
40class ExecutorBase;
41
46class GcTcpHub : private Notifiable, private Atomic
47{
48public:
54 GcTcpHub(CanHubFlow *can_hub, int port);
55 ~GcTcpHub();
56
59 {
60 return tcpListener_.is_started();
61 }
62
64 unsigned get_num_clients()
65 {
66 return numClients_;
67 }
68
69private:
74 void on_new_connection(int fd);
75
78 void notify() override;
79
84 unsigned numClients_ {0};
87};
88
89#endif // _UTILS_GCTCPHUB_HXX_
Lightweight locking class for protecting small critical sections.
Definition Atomic.hxx:130
This class implements an execution of tasks pulled off an input queue.
Definition Executor.hxx:64
This class runs a CAN-bus HUB listening on TCP socket using the gridconnect format.
Definition GcTcpHub.hxx:47
bool is_started()
Definition GcTcpHub.hxx:58
unsigned numClients_
How many clients are connected right now.
Definition GcTcpHub.hxx:84
SocketListener tcpListener_
Helper object representing the listening on the socket.
Definition GcTcpHub.hxx:86
void notify() override
Error callback from the gridconnect socket.
Definition GcTcpHub.cxx:55
void on_new_connection(int fd)
Callback when a new connection arrives.
Definition GcTcpHub.cxx:42
CanHubFlow * canHub_
Definition GcTcpHub.hxx:82
unsigned get_num_clients()
Definition GcTcpHub.hxx:64
An object that can schedule itself on an executor to run.