Fawkes API  Fawkes Development Version
fawkes::ConnectionDispatcher Class Reference

#include <>>

Inheritance diagram for fawkes::ConnectionDispatcher:

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...
 
FawkesNetworkClientget_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...
 
- Public Member Functions inherited from fawkes::FawkesNetworkClientHandler
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...
 

Detailed Description

Watches network client events and dispatches them as signals.

Author
Tim Niemueller

Definition at line 44 of file connection_dispatcher.h.

Constructor & Destructor Documentation

◆ ConnectionDispatcher() [1/2]

fawkes::ConnectionDispatcher::ConnectionDispatcher ( unsigned int  cid = FAWKES_CID_OBSERVER_MODE)

Constructor.

Parameters
cidcomponent ID to register this dispatcher for. This is relevant if you want to use the message received signal!

Definition at line 47 of file connection_dispatcher.cpp.

◆ ConnectionDispatcher() [2/2]

fawkes::ConnectionDispatcher::ConnectionDispatcher ( const char *  hostname,
unsigned short int  port,
unsigned int  cid = FAWKES_CID_OBSERVER_MODE 
)

Constructor.

Parameters
cidcomponent ID to register this dispatcher for. This is relevant if you want to use the message received signal!
hostnamehostname to connect to
portport to connect to

Definition at line 63 of file connection_dispatcher.cpp.

◆ ~ConnectionDispatcher()

fawkes::ConnectionDispatcher::~ConnectionDispatcher ( )
virtual

Destructor.

Definition at line 76 of file connection_dispatcher.cpp.

References on_connection_died(), on_connection_established(), and on_message_received().

Member Function Documentation

◆ connection_died()

void fawkes::ConnectionDispatcher::connection_died ( unsigned int  id)
throw (
)
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.

Parameters
idthe id of the calling client

Implements fawkes::FawkesNetworkClientHandler.

Definition at line 195 of file connection_dispatcher.cpp.

◆ connection_established()

void fawkes::ConnectionDispatcher::connection_established ( unsigned int  id)
throw (
)
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.

Parameters
idthe id of the calling client

Implements fawkes::FawkesNetworkClientHandler.

Definition at line 201 of file connection_dispatcher.cpp.

◆ deregistered()

void fawkes::ConnectionDispatcher::deregistered ( unsigned int  id)
throw (
)
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.

Parameters
idthe id of the calling client

Implements fawkes::FawkesNetworkClientHandler.

Definition at line 181 of file connection_dispatcher.cpp.

◆ get_client()

◆ inbound_received()

void fawkes::ConnectionDispatcher::inbound_received ( FawkesNetworkMessage m,
unsigned int  id 
)
throw (
)
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.

Parameters
mMessage to handle
idthe id of the calling client

Implements fawkes::FawkesNetworkClientHandler.

Definition at line 187 of file connection_dispatcher.cpp.

◆ on_connection_died()

void fawkes::ConnectionDispatcher::on_connection_died ( )
protectedvirtual

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 159 of file connection_dispatcher.cpp.

References fawkes::LockQueue< Type >::lock().

Referenced by ~ConnectionDispatcher().

◆ on_connection_established()

void fawkes::ConnectionDispatcher::on_connection_established ( )
protectedvirtual

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 150 of file connection_dispatcher.cpp.

Referenced by ~ConnectionDispatcher().

◆ on_message_received()

void fawkes::ConnectionDispatcher::on_message_received ( )
protectedvirtual

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 168 of file connection_dispatcher.cpp.

Referenced by ~ConnectionDispatcher().

◆ operator bool()

fawkes::ConnectionDispatcher::operator bool ( )

Check if client is set and connection has been established.

Returns
true if a client exists and a connection is established, false otherwise.

Definition at line 141 of file connection_dispatcher.cpp.

◆ set_cid()

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.

Parameters
cidcomponent ID

Definition at line 99 of file connection_dispatcher.cpp.

◆ set_client()

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.

Parameters
clientFawkes network client to set.

Definition at line 115 of file connection_dispatcher.cpp.

Referenced by fawkes::PluginTreeView::set_network_client().

◆ signal_connected()

sigc::signal< void > fawkes::ConnectionDispatcher::signal_connected ( )

Get "connected" signal.

The "connected" signal is emitted when the connection has been established.

Returns
"connected" signal

Definition at line 222 of file connection_dispatcher.cpp.

Referenced by Bumblebee2CalibGtkWindow::Bumblebee2CalibGtkWindow(), fawkes::ServiceSelectorCBE::initialize(), NaoGuiGtkWindow::NaoGuiGtkWindow(), fawkes::ServiceSelectorCBE::signal_connected(), and SkillGuiGtkWindow::SkillGuiGtkWindow().

◆ signal_disconnected()

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.

Returns
"disconnected" signal

Definition at line 233 of file connection_dispatcher.cpp.

Referenced by Bumblebee2CalibGtkWindow::Bumblebee2CalibGtkWindow(), fawkes::ServiceSelectorCBE::initialize(), NaoGuiGtkWindow::NaoGuiGtkWindow(), fawkes::ServiceSelectorCBE::signal_disconnected(), and SkillGuiGtkWindow::SkillGuiGtkWindow().

◆ signal_message_received()

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.

Returns
"message received" signal

Definition at line 212 of file connection_dispatcher.cpp.


The documentation for this class was generated from the following files: