Fawkes API
Fawkes Development Version
|
Watches network client events and dispatches them as signals. More...
#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 () |
This handler has been deregistered. More... | |
virtual void | inbound_received (FawkesNetworkMessage *m, unsigned int id) throw () |
Called for incoming messages. More... | |
virtual void | connection_died (unsigned int id) throw () |
Client connection died. More... | |
virtual void | connection_established (unsigned int id) throw () |
Client has established a connection. More... | |
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 37 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 41 of file connection_dispatcher.cpp.
References fawkes::FawkesNetworkClient::register_handler().
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 58 of file connection_dispatcher.cpp.
References fawkes::FawkesNetworkClient::register_handler().
|
virtual |
Destructor.
Definition at line 71 of file connection_dispatcher.cpp.
References on_connection_died(), on_connection_established(), on_message_received(), and set_client().
|
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 196 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 203 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 180 of file connection_dispatcher.cpp.
FawkesNetworkClient * fawkes::ConnectionDispatcher::get_client | ( | ) |
Get client.
Definition at line 126 of file connection_dispatcher.cpp.
Referenced by fawkes::LogView::clear(), fawkes::LogView::get_client(), fawkes::ServiceSelectorCBE::get_network_client(), fawkes::ServiceSelectorCBE::on_btn_connect_clicked(), fawkes::ServiceSelectorCBE::on_service_selected(), fawkes::LogView::set_client(), fawkes::PluginTreeView::set_gconf_prefix(), SkillGuiGtkWindow::SkillGuiGtkWindow(), Bumblebee2CalibGtkWindow::~Bumblebee2CalibGtkWindow(), fawkes::LogView::~LogView(), NaoGuiGtkWindow::~NaoGuiGtkWindow(), fawkes::PluginTreeView::~PluginTreeView(), and SkillGuiGtkWindow::~SkillGuiGtkWindow().
|
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 187 of file connection_dispatcher.cpp.
References fawkes::LockQueue< Type >::push_locked().
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 156 of file connection_dispatcher.cpp.
Referenced by ~ConnectionDispatcher().
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 146 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.
References fawkes::LockQueue< Type >::lock(), fawkes::LockQueue< Type >::unlock(), and fawkes::RefCount::unref().
Referenced by ~ConnectionDispatcher().
fawkes::ConnectionDispatcher::operator bool | ( | ) |
Check if client is set and connection has been established.
Definition at line 136 of file connection_dispatcher.cpp.
References fawkes::FawkesNetworkClient::connected().
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 93 of file connection_dispatcher.cpp.
References fawkes::FawkesNetworkClient::deregister_handler(), and fawkes::FawkesNetworkClient::register_handler().
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 110 of file connection_dispatcher.cpp.
References fawkes::FawkesNetworkClient::deregister_handler(), and fawkes::FawkesNetworkClient::register_handler().
Referenced by fawkes::LogView::set_client(), fawkes::PluginTreeView::set_network_client(), and ~ConnectionDispatcher().
sigc::signal< void > fawkes::ConnectionDispatcher::signal_connected | ( | ) |
Get "connected" signal.
The "connected" signal is emitted when the connection has been established.
Definition at line 226 of file connection_dispatcher.cpp.
Referenced by Bumblebee2CalibGtkWindow::Bumblebee2CalibGtkWindow(), fawkes::ServiceSelectorCBE::initialize(), NaoGuiGtkWindow::NaoGuiGtkWindow(), fawkes::PluginTreeView::PluginTreeView(), fawkes::ServiceSelectorCBE::signal_connected(), SkillGuiGtkWindow::SkillGuiGtkWindow(), fawkes::LogView::~LogView(), and NetLogGuiGtkWindow::~NetLogGuiGtkWindow().
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 238 of file connection_dispatcher.cpp.
Referenced by Bumblebee2CalibGtkWindow::Bumblebee2CalibGtkWindow(), fawkes::ServiceSelectorCBE::initialize(), NaoGuiGtkWindow::NaoGuiGtkWindow(), fawkes::PluginTreeView::PluginTreeView(), fawkes::ServiceSelectorCBE::signal_disconnected(), SkillGuiGtkWindow::SkillGuiGtkWindow(), fawkes::LogView::~LogView(), and NetLogGuiGtkWindow::~NetLogGuiGtkWindow().
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 215 of file connection_dispatcher.cpp.
Referenced by fawkes::PluginTreeView::PluginTreeView(), and fawkes::LogView::~LogView().