#include <asebaros.h>
Public Member Functions | |
AsebaDashelHub (AsebaROS *asebaROS, unsigned port, bool forward) | |
void | operator() () |
run the hub | |
void | sendMessage (Aseba::Message *message, bool doLock, Dashel::Stream *sourceStream=0) |
void | startThread () |
start the hub thread | |
void | stopThread () |
stop the hub thread and wait for its termination | |
Protected Member Functions | |
virtual void | connectionClosed (Dashel::Stream *stream, bool abnormal) |
virtual void | connectionCreated (Dashel::Stream *stream) |
virtual void | incomingData (Dashel::Stream *stream) |
Private Attributes | |
AsebaROS * | asebaROS |
thread for the hub | |
bool | forward |
should we only forward messages instead of transmit them back to the sender | |
boost::thread * | thread |
Definition at line 32 of file asebaros.h.
AsebaDashelHub::AsebaDashelHub | ( | AsebaROS * | asebaROS, | |
unsigned | port, | |||
bool | forward | |||
) |
Creates the hub, listen to TCP on port, and creates a DBus interace.
port | port on which to listen for incoming connections | |
forward | should we only forward messages instead of transmit them back to the sender |
Definition at line 23 of file asebaros.cpp.
void AsebaDashelHub::connectionClosed | ( | Dashel::Stream * | , | |
bool | ||||
) | [protected, virtual] |
Called when target closes connection. The only valid method to call on the stream is getTargetName(), input/output operations are forbidden. You must not call closeStream(stream) from within this method for the same stream as the one passed as parameter. Subclass can implement this method. Called with the stream lock held.
stream | stream to the target. | |
abnormal | whether the connection was closed during step (abnormal == false) or when an operation was performed (abnormal == true) |
Reimplemented from Dashel::Hub.
Definition at line 133 of file asebaros.cpp.
void AsebaDashelHub::connectionCreated | ( | Dashel::Stream * | ) | [protected, virtual] |
Called when any data connection is created. It is not called when a listening connection (eg tcpin:) is created. If the stream is closed during this method, an exception occurs: the caller is responsible to handle it. The stream is already inserted in the stream list when this function is called. Subclass can implement this method. Called with the stream lock held.
stream | stream to the target |
Reimplemented from Dashel::Hub.
Definition at line 119 of file asebaros.cpp.
void AsebaDashelHub::incomingData | ( | Dashel::Stream * | ) | [protected, virtual] |
Called when data is available for reading on the stream. If the stream is closed during this method, an exception occurs: Hub stops the execution of this method and calls connectionClosed(); objects dynamically allocated must thus be handled with auto_ptr. If step() is used, subclass must implement this method and call read at least once. Called with the stream lock held.
stream | stream to the target |
Reimplemented from Dashel::Hub.
Definition at line 95 of file asebaros.cpp.
void AsebaDashelHub::operator() | ( | ) |
run the hub
Definition at line 73 of file asebaros.cpp.
void AsebaDashelHub::sendMessage | ( | Aseba::Message * | message, | |
bool | doLock, | |||
Dashel::Stream * | sourceStream = 0 | |||
) |
Sends a message to Dashel peers. Does not delete the message, should be called by the main thread.
message | aseba message to send | |
sourceStream | originate of the message, if from Dashel. |
Definition at line 40 of file asebaros.cpp.
void AsebaDashelHub::startThread | ( | ) |
start the hub thread
Definition at line 80 of file asebaros.cpp.
void AsebaDashelHub::stopThread | ( | ) |
stop the hub thread and wait for its termination
Definition at line 85 of file asebaros.cpp.
AsebaROS* AsebaDashelHub::asebaROS [private] |
bool AsebaDashelHub::forward [private] |
should we only forward messages instead of transmit them back to the sender
Definition at line 37 of file asebaros.h.
boost::thread* AsebaDashelHub::thread [private] |
Definition at line 35 of file asebaros.h.