24#ifndef _NETCOMM_FAWKES_CLIENT_H_
25#define _NETCOMM_FAWKES_CLIENT_H_
27#include <core/exception.h>
28#include <core/utils/lock_map.h>
29#include <netcomm/fawkes/component_ids.h>
30#include <netcomm/fawkes/message.h>
31#include <netcomm/fawkes/message_queue.h>
32#include <sys/socket.h>
39class FawkesNetworkClientHandler;
40class FawkesNetworkClientSendThread;
41class FawkesNetworkClientRecvThread;
49#define FAWKES_TCP_PORT 1910
64 void connect(
const char *host,
unsigned short int port);
65 void connect(
const char *hostname,
const struct sockaddr *addr, socklen_t addrlen);
66 void connect(
const char *hostname,
const struct sockaddr_storage &addr);
71 void wait(
unsigned int component_id,
unsigned int timeout_sec = 15);
72 void wake(
unsigned int component_id);
82 unsigned int id()
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();
98 unsigned short int port_;
106 Mutex * connest_mutex_;
108 bool connest_interrupted_;
112 std::map<unsigned int, bool> recv_received_;
115 bool recv_slave_alive_;
116 bool send_slave_alive_;
118 bool connection_died_recently;
119 Mutex * slave_status_mutex;
123 struct sockaddr *addr_;
Base class for exceptions in Fawkes.
Message handler for FawkesNetworkClient.
Fawkes network client receive thread.
Fawkes network client send thread.
Simple Fawkes network client.
void wake(unsigned int component_id)
Wake a waiting thread.
void register_handler(FawkesNetworkClientHandler *handler, unsigned int component_id)
Register handler.
~FawkesNetworkClient()
Destructor.
const char * get_hostname() const
Get the client's hostname.
void wait(unsigned int component_id, unsigned int timeout_sec=15)
Wait for messages for component ID.
bool has_id() const
Check whether the client has an id.
void enqueue_and_wait(FawkesNetworkMessage *message, unsigned int timeout_sec=15)
Enqueue message to send and wait for answer.
void connect()
Connect to remote.
FawkesNetworkClient()
Constructor.
void disconnect()
Disconnect socket.
void deregister_handler(unsigned int component_id)
Deregister handler.
unsigned int id() const
Get the client's ID.
bool connected() const noexcept
Check if connection is alive.
void enqueue(FawkesNetworkMessage *message)
Enqueue message to send.
void interrupt_connect()
Interrupt connect().
Representation of a message that is sent over the network.
Client handler has already been registered.
HandlerAlreadyRegisteredException()
Costructor.
Mutex mutual exclusion lock.
TCP stream socket over IP.
Wait until a given condition holds.
Fawkes library namespace.