Fawkes API
Fawkes Development Version
|
Stream server for protobuf message transmission. More...
#include <>>
Public Types | |
typedef unsigned int | ClientID |
ID to identify connected clients. More... | |
Public Member Functions | |
ProtobufStreamServer (unsigned short port) | |
Constructor. More... | |
ProtobufStreamServer (unsigned short port, std::vector< std::string > &proto_path) | |
Constructor. More... | |
ProtobufStreamServer (unsigned short port, MessageRegister *mr) | |
Constructor. More... | |
~ProtobufStreamServer () | |
Destructor. More... | |
void | send (ClientID client, uint16_t component_id, uint16_t msg_type, google::protobuf::Message &m) |
Send a message to the given client. More... | |
void | send (ClientID client, uint16_t component_id, uint16_t msg_type, std::shared_ptr< google::protobuf::Message > m) |
Send a message. More... | |
void | send (ClientID client, std::shared_ptr< google::protobuf::Message > m) |
Send a message. More... | |
void | send (ClientID client, google::protobuf::Message &m) |
Send a message. More... | |
void | send_to_all (uint16_t component_id, uint16_t msg_type, google::protobuf::Message &m) |
Send a message to all clients. More... | |
void | send_to_all (uint16_t component_id, uint16_t msg_type, std::shared_ptr< google::protobuf::Message > m) |
Send a message to all clients. More... | |
void | send_to_all (std::shared_ptr< google::protobuf::Message > m) |
Send a message to all clients. More... | |
void | send_to_all (google::protobuf::Message &m) |
Send a message to all clients. More... | |
void | disconnect (ClientID client) |
Disconnect specific client. More... | |
MessageRegister & | message_register () |
Get the server's message register. More... | |
boost::signals2::signal< void(ClientID, uint16_t, uint16_t, std::shared_ptr< google::protobuf::Message >)> & | signal_received () |
Signal that is invoked when a message has been received. More... | |
boost::signals2::signal< void(ClientID, uint16_t, uint16_t, std::string)> & | signal_receive_failed () |
Signal that is invoked when receiving a message failed. More... | |
boost::signals2::signal< void(ClientID, boost::asio::ip::tcp::endpoint &)> & | signal_connected () |
Signal that is invoked when a new client has connected. More... | |
boost::signals2::signal< void(ClientID, const boost::system::error_code &)> & | signal_disconnected () |
Signal that is invoked when a new client has disconnected. More... | |
Stream server for protobuf message transmission.
The server opens a TCP socket (IPv4) and waits for incoming connections. Each incoming connection is given a unique client ID. Signals are provided that can be used to react to connections and incoming data.
typedef unsigned int protobuf_comm::ProtobufStreamServer::ClientID |
protobuf_comm::ProtobufStreamServer::ProtobufStreamServer | ( | unsigned short | port | ) |
protobuf_comm::ProtobufStreamServer::ProtobufStreamServer | ( | unsigned short | port, |
std::vector< std::string > & | proto_path | ||
) |
Constructor.
port | port to listen on |
proto_path | file paths to search for proto files. All message types within these files will automatically be registered and available for dynamic message creation. |
Definition at line 272 of file server.cpp.
protobuf_comm::ProtobufStreamServer::ProtobufStreamServer | ( | unsigned short | port, |
MessageRegister * | mr | ||
) |
Constructor.
port | port to listen on |
mr | message register to use to (de)serialize messages |
Definition at line 291 of file server.cpp.
protobuf_comm::ProtobufStreamServer::~ProtobufStreamServer | ( | ) |
Destructor.
Definition at line 307 of file server.cpp.
void protobuf_comm::ProtobufStreamServer::disconnect | ( | ClientID | client | ) |
Disconnect specific client.
client | client ID to disconnect from |
Definition at line 450 of file server.cpp.
Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), oprs_protobuf::OpenPRSProtobuf::oprs_pb_disconnect(), and signal_disconnected().
|
inline |
void protobuf_comm::ProtobufStreamServer::send | ( | ClientID | client, |
uint16_t | component_id, | ||
uint16_t | msg_type, | ||
google::protobuf::Message & | m | ||
) |
Send a message to the given client.
client | ID of the client to addresss |
component_id | ID of the component to address |
msg_type | numeric message type |
m | message to send |
Definition at line 324 of file server.cpp.
Referenced by protobuf_clips::ClipsProtobufCommunicator::disable_server(), oprs_protobuf::OpenPRSProtobuf::oprs_pb_send(), send(), send_to_all(), and signal_disconnected().
void protobuf_comm::ProtobufStreamServer::send | ( | ClientID | client, |
uint16_t | component_id, | ||
uint16_t | msg_type, | ||
std::shared_ptr< google::protobuf::Message > | m | ||
) |
Send a message.
client | ID of the client to addresss |
component_id | ID of the component to address |
msg_type | numeric message type |
m | Message to send |
Definition at line 342 of file server.cpp.
References send().
void protobuf_comm::ProtobufStreamServer::send | ( | ClientID | client, |
std::shared_ptr< google::protobuf::Message > | m | ||
) |
Send a message.
client | ID of the client to addresss |
m | Message to send, the message must have an CompType enum type to specify component ID and message type. |
Definition at line 386 of file server.cpp.
References send().
void protobuf_comm::ProtobufStreamServer::send | ( | ClientID | client, |
google::protobuf::Message & | m | ||
) |
Send a message.
client | ID of the client to addresss |
m | Message to send, the message must have an CompType enum type to specify component ID and message type. |
Definition at line 354 of file server.cpp.
References send().
void protobuf_comm::ProtobufStreamServer::send_to_all | ( | uint16_t | component_id, |
uint16_t | msg_type, | ||
google::protobuf::Message & | m | ||
) |
Send a message to all clients.
component_id | ID of the component to address |
msg_type | numeric message type |
m | message to send |
Definition at line 397 of file server.cpp.
References send().
void protobuf_comm::ProtobufStreamServer::send_to_all | ( | uint16_t | component_id, |
uint16_t | msg_type, | ||
std::shared_ptr< google::protobuf::Message > | m | ||
) |
Send a message to all clients.
component_id | ID of the component to address |
msg_type | numeric message type |
m | message to send |
Definition at line 412 of file server.cpp.
References send().
void protobuf_comm::ProtobufStreamServer::send_to_all | ( | std::shared_ptr< google::protobuf::Message > | m | ) |
Send a message to all clients.
m | message to send |
Definition at line 425 of file server.cpp.
References send().
void protobuf_comm::ProtobufStreamServer::send_to_all | ( | google::protobuf::Message & | m | ) |
Send a message to all clients.
m | message to send |
Definition at line 437 of file server.cpp.
References send().
|
inline |
Signal that is invoked when a new client has connected.
Definition at line 114 of file server.h.
Referenced by protobuf_clips::ClipsProtobufCommunicator::enable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_enable_server().
|
inline |
Signal that is invoked when a new client has disconnected.
Definition at line 120 of file server.h.
References disconnect(), and send().
Referenced by protobuf_clips::ClipsProtobufCommunicator::enable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_enable_server().
|
inline |
Signal that is invoked when receiving a message failed.
Definition at line 108 of file server.h.
Referenced by protobuf_clips::ClipsProtobufCommunicator::enable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_enable_server().
|
inline |
Signal that is invoked when a message has been received.
Definition at line 102 of file server.h.
Referenced by protobuf_clips::ClipsProtobufCommunicator::enable_server(), and oprs_protobuf::OpenPRSProtobuf::oprs_pb_enable_server().