24 #ifndef __NETCOMM_FAWKES_CLIENT_H_ 25 #define __NETCOMM_FAWKES_CLIENT_H_ 27 #include <netcomm/fawkes/message_queue.h> 28 #include <netcomm/fawkes/message.h> 29 #include <netcomm/fawkes/component_ids.h> 31 #include <core/exception.h> 32 #include <core/utils/lock_map.h> 33 #include <sys/socket.h> 40 class FawkesNetworkClientHandler;
41 class FawkesNetworkClientSendThread;
42 class FawkesNetworkClientRecvThread;
50 #define FAWKES_TCP_PORT 1910 60 unsigned short int port);
65 void connect(
const char *host,
unsigned short int port);
66 void connect(
const char *hostname,
const struct sockaddr *addr, socklen_t addrlen);
67 void connect(
const char *hostname,
const struct sockaddr_storage &addr);
72 void wait(
unsigned int component_id,
unsigned int timeout_sec = 15);
73 void wake(
unsigned int component_id);
83 unsigned int id()
const;
89 void notify_of_connection_established();
90 void notify_of_connection_dead();
92 void wake_handlers(
unsigned int cid);
94 void connection_died();
95 void set_send_slave_alive();
96 void set_recv_slave_alive();
99 unsigned short int __port;
107 Mutex *__connest_mutex;
109 bool __connest_interrupted;
113 std::map<unsigned int, bool> __recv_received;
116 bool __recv_slave_alive;
117 bool __send_slave_alive;
119 bool connection_died_recently;
120 Mutex *slave_status_mutex;
124 struct sockaddr *addr_;
~FawkesNetworkClient()
Destructor.
Message handler for FawkesNetworkClient.
void wake(unsigned int component_id)
Wake a waiting thread.
void interrupt_connect()
Interrupt connect().
Wait until a given condition holds.
void enqueue_and_wait(FawkesNetworkMessage *message, unsigned int timeout_sec=15)
Enqueue message to send and wait for answer.
Simple Fawkes network client.
Fawkes library namespace.
void disconnect()
Disconnect socket.
void register_handler(FawkesNetworkClientHandler *handler, unsigned int component_id)
Register handler.
void enqueue(FawkesNetworkMessage *message)
Enqueue message to send.
void wait(unsigned int component_id, unsigned int timeout_sec=15)
Wait for messages for component ID.
Representation of a message that is sent over the network.
void connect()
Connect to remote.
bool has_id() const
Check whether the client has an id.
Fawkes network client send thread.
unsigned int id() const
Get the client's ID.
TCP stream socket over IP.
HandlerAlreadyRegisteredException()
Costructor.
Base class for exceptions in Fawkes.
Client handler has already been registered.
FawkesNetworkClient()
Constructor.
void deregister_handler(unsigned int component_id)
Deregister handler.
const char * get_hostname() const
Get the client's hostname.
bool connected() const
Check if connection is alive.
Mutex mutual exclusion lock.
Fawkes network client receive thread.