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>
39 class FawkesNetworkClientHandler;
40 class FawkesNetworkClientSendThread;
41 class FawkesNetworkClientRecvThread;
49 #define FAWKES_TCP_PORT 1910
59 unsigned short int port,
const char *ip = NULL);
64 void connect(
const char *hostname,
unsigned short int port);
65 void connect(
const char *hostname,
const char *ip,
unsigned short int port);
70 void wait(
unsigned int component_id,
unsigned int timeout_sec = 15);
71 void wake(
unsigned int component_id);
81 unsigned int id()
const;
84 const char *
get_ip()
const;
88 void notify_of_connection_established();
89 void notify_of_connection_dead();
91 void wake_handlers(
unsigned int cid);
93 void connection_died();
94 void set_send_slave_alive();
95 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;
~FawkesNetworkClient()
Destructor.
Message handler for FawkesNetworkClient.
void wake(unsigned int component_id)
Wake a waiting thread.
unsigned int id() const
Get the client's ID.
void interrupt_connect()
Interrupt connect().
bool has_id() const
Check whether the client has an id.
const char * get_hostname() const
Get the client's hostname.
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.
const char * get_ip() const
Get the client's ip.
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.
Fawkes network client send thread.
TCP stream socket over IP.
HandlerAlreadyRegisteredException()
Costructor.
Base class for exceptions in Fawkes.
Client handler has already been registered.
bool connected() const
Check if connection is alive.
FawkesNetworkClient()
Constructor.
void deregister_handler(unsigned int component_id)
Deregister handler.
Mutex mutual exclusion lock.
Fawkes network client receive thread.