Fawkes API
Fawkes Development Version
|
#include <>>
Public Member Functions | |
ConnectionDispatcher (unsigned int cid=FAWKES_CID_OBSERVER_MODE) | |
Constructor. More... | |
ConnectionDispatcher (const char *hostname, unsigned short int port, unsigned int cid=FAWKES_CID_OBSERVER_MODE) | |
Constructor. More... | |
virtual | ~ConnectionDispatcher () |
Destructor. More... | |
void | set_cid (unsigned int cid) |
Set component ID. More... | |
void | set_client (FawkesNetworkClient *client) |
Set Fawkes network client. More... | |
FawkesNetworkClient * | get_client () |
Get client. More... | |
sigc::signal< void > | signal_connected () |
Get "connected" signal. More... | |
sigc::signal< void > | signal_disconnected () |
Get "disconnected" signal. More... | |
sigc::signal< void, FawkesNetworkMessage * > | signal_message_received () |
Get "message received" signal. More... | |
virtual void | deregistered (unsigned int id) throw () |
virtual void | inbound_received (FawkesNetworkMessage *m, unsigned int id) throw () |
virtual void | connection_died (unsigned int id) throw () |
virtual void | connection_established (unsigned int id) throw () |
operator bool () | |
Check if client is set and connection has been established. More... | |
![]() | |
virtual | ~FawkesNetworkClientHandler () |
Empty virtual destructor. More... | |
Protected Member Functions | |
virtual void | on_connection_established () |
Internal event handler. More... | |
virtual void | on_connection_died () |
Internal event handler. More... | |
virtual void | on_message_received () |
Internal event handler. More... | |
Watches network client events and dispatches them as signals.
Definition at line 42 of file connection_dispatcher.h.
fawkes::ConnectionDispatcher::ConnectionDispatcher | ( | unsigned int | cid = FAWKES_CID_OBSERVER_MODE | ) |
Constructor.
cid | component ID to register this dispatcher for. This is relevant if you want to use the message received signal! |
Definition at line 45 of file connection_dispatcher.cpp.
fawkes::ConnectionDispatcher::ConnectionDispatcher | ( | const char * | hostname, |
unsigned short int | port, | ||
unsigned int | cid = FAWKES_CID_OBSERVER_MODE |
||
) |
Constructor.
cid | component ID to register this dispatcher for. This is relevant if you want to use the message received signal! |
hostname | hostname to connect to |
port | port to connect to |
Definition at line 61 of file connection_dispatcher.cpp.
|
virtual |
Destructor.
Definition at line 74 of file connection_dispatcher.cpp.
References on_connection_died(), on_connection_established(), and on_message_received().
|
virtual |
Client connection died. This method is used to inform handlers that the connection has died for any reason. No more data can be send and no more messages should be enqueued because it is unclear when they would be sent.
id | the id of the calling client |
Implements fawkes::FawkesNetworkClientHandler.
Definition at line 193 of file connection_dispatcher.cpp.
|
virtual |
Client has established a connection. Whenever the client establishes a connection this is signaled to handlers with this method. You can register to a client at any time, you may even enqueue messages to a client while the connection is dead. If the client at some point gets connected again, the messages will then be send out in one go. You should use this in your application though to only send data if the connection is alive and you should let the user know about the connection status.
id | the id of the calling client |
Implements fawkes::FawkesNetworkClientHandler.
Definition at line 199 of file connection_dispatcher.cpp.
|
virtual |
This handler has been deregistered. This is called when this handler is deregistered from the FawkesNetworkClient. Sometimes you may not want to allow this and post a big fat warning into the log.
id | the id of the calling client |
Implements fawkes::FawkesNetworkClientHandler.
Definition at line 179 of file connection_dispatcher.cpp.
FawkesNetworkClient * fawkes::ConnectionDispatcher::get_client | ( | ) |
Get client.
Definition at line 130 of file connection_dispatcher.cpp.
Referenced by fawkes::ServiceSelectorCBE::get_network_client(), fawkes::ServiceSelectorCBE::on_btn_connect_clicked(), fawkes::ServiceSelectorCBE::on_service_selected(), SkillGuiGtkWindow::SkillGuiGtkWindow(), and fawkes::PluginTreeView::~PluginTreeView().
|
virtual |
Called for incoming messages. This is called when an incoming message has been received. If this method was called one or more times then the a previously carried out wait(cid) call will continue.
m | Message to handle |
id | the id of the calling client |
Implements fawkes::FawkesNetworkClientHandler.
Definition at line 185 of file connection_dispatcher.cpp.
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 157 of file connection_dispatcher.cpp.
References fawkes::LockQueue< Type >::lock().
Referenced by ~ConnectionDispatcher().
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 148 of file connection_dispatcher.cpp.
Referenced by ~ConnectionDispatcher().
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 166 of file connection_dispatcher.cpp.
Referenced by ~ConnectionDispatcher().
fawkes::ConnectionDispatcher::operator bool | ( | ) |
Check if client is set and connection has been established.
Definition at line 139 of file connection_dispatcher.cpp.
void fawkes::ConnectionDispatcher::set_cid | ( | unsigned int | cid | ) |
Set component ID.
Set the component ID you want to register this connection dispatcher on. By default the connection dispatcher uses the observer mode to only provide connection status signals. If you want to use the dispatcher to be signaled for incoming messages you have to set the appropriate component ID.
cid | component ID |
Definition at line 97 of file connection_dispatcher.cpp.
void fawkes::ConnectionDispatcher::set_client | ( | FawkesNetworkClient * | client | ) |
Set Fawkes network client.
The instance you set is not owned by the ConnectionDispatcher, it's only used. You have to delete it when finished. Similarly you have to make sure that the client is valid as long as it is set on the dispatcher.
client | Fawkes network client to set. |
Definition at line 113 of file connection_dispatcher.cpp.
Referenced by fawkes::PluginTreeView::set_network_client().
sigc::signal< void > fawkes::ConnectionDispatcher::signal_connected | ( | ) |
Get "connected" signal.
The "connected" signal is emitted when the connection has been established.
Definition at line 220 of file connection_dispatcher.cpp.
Referenced by Bumblebee2CalibGtkWindow::Bumblebee2CalibGtkWindow(), fawkes::ServiceSelectorCBE::initialize(), NaoGuiGtkWindow::NaoGuiGtkWindow(), fawkes::ServiceSelectorCBE::signal_connected(), and SkillGuiGtkWindow::SkillGuiGtkWindow().
sigc::signal< void > fawkes::ConnectionDispatcher::signal_disconnected | ( | ) |
Get "disconnected" signal.
The "disconnected" signal is emitted when the connection has died, for example because the other peer closed the connection.
Definition at line 231 of file connection_dispatcher.cpp.
Referenced by Bumblebee2CalibGtkWindow::Bumblebee2CalibGtkWindow(), fawkes::ServiceSelectorCBE::initialize(), NaoGuiGtkWindow::NaoGuiGtkWindow(), fawkes::ServiceSelectorCBE::signal_disconnected(), and SkillGuiGtkWindow::SkillGuiGtkWindow().
sigc::signal< void, FawkesNetworkMessage * > fawkes::ConnectionDispatcher::signal_message_received | ( | ) |
Get "message received" signal.
The "message received" signal is emitted whenever a FawkesNetworkMessage has been received.
Definition at line 210 of file connection_dispatcher.cpp.