trikRuntime
|
Implementation of mailboxes system. More...
#include <mailbox.h>
Public Slots | |
void | connect (const QString &ip, int port) override |
void | connect (const QString &ip) override |
void | send (int hullNumber, const QString &message) override |
void | send (const QString &message) override |
bool | hasMessages () override |
QString | receive (bool wait=true) override |
int | myHullNumber () const override |
void | renewIp () override |
Public Slots inherited from trikNetwork::MailboxInterface | |
virtual void | connect (const QString &ip, int port)=0 |
Connects to robot by IP and port. More... | |
virtual void | connect (const QString &ip)=0 |
Connects to robot by IP and uses port of local mailbox server as a port on remote robot. More... | |
virtual void | send (int hullNumber, const QString &message)=0 |
Sends message to a robot with given hull number. More... | |
virtual void | send (const QString &message)=0 |
Sends message to all known robots. More... | |
virtual bool | hasMessages ()=0 |
Returns true if there are incoming messages. Returns immediately. More... | |
virtual void | renewIp ()=0 |
Tries to get renewed IP address. More... | |
virtual QString | receive (bool wait=true)=0 |
Receives and returns one incoming message. More... | |
virtual int | myHullNumber () const =0 |
Returns hull number of this robot. More... | |
Signals | |
void | stopWaitingSignal () |
Used to interrupt waiting for new message. More... | |
Signals inherited from trikNetwork::MailboxInterface | |
void | newMessage (int sender, const QString &message) |
Emitted when new message is received from a robot with given hull number. More... | |
void | connectionStatusChanged (bool connected) |
Emitted when a mailbox either receives the first connection (connected == true) or loses the last one. More... | |
Public Member Functions | |
Mailbox (int port) | |
Constructor. More... | |
Mailbox (const trikKernel::Configurer &configurer) | |
Constructor. More... | |
~Mailbox () override | |
bool | isConnected () const override |
Returns true if at least one opened mailbox connection presents at the moment. More... | |
void | setHullNumber (int myHullNumber) override |
Sets hull number of this robot and sends a message to update hull number to all known robots. More... | |
QHostAddress | serverIp () const override |
Returns IP of a leader robot, or empty QHostAddress if we are not connected. More... | |
QHostAddress | myIp () const override |
Returns our IP address, or empty QHostAddress if we are not connected. More... | |
void | clearQueue () override |
Clears message queue. More... | |
bool | isEnabled () override |
Returns true if mailbox is enabled in current configuration. More... | |
void | stopWaiting () override |
Stops waiting for messages. More... | |
Implementation of mailboxes system.
Mailbox::Mailbox | ( | int | port | ) |
Constructor.
port | - port for mailbox server. |
Mailbox::Mailbox | ( | const trikKernel::Configurer & | configurer | ) |
Constructor.
configurer | - configurer object that contains preparsed XML config. |
|
override |
|
overridevirtual |
Clears message queue.
Implements trikNetwork::MailboxInterface.
|
overrideslot |
|
overrideslot |
|
overrideslot |
|
overridevirtual |
Returns true if at least one opened mailbox connection presents at the moment.
Implements trikNetwork::MailboxInterface.
|
overridevirtual |
Returns true if mailbox is enabled in current configuration.
Implements trikNetwork::MailboxInterface.
|
overrideslot |
|
overridevirtual |
Returns our IP address, or empty QHostAddress if we are not connected.
Implements trikNetwork::MailboxInterface.
|
overrideslot |
|
overrideslot |
|
overrideslot |
|
overrideslot |
|
overridevirtual |
Returns IP of a leader robot, or empty QHostAddress if we are not connected.
Implements trikNetwork::MailboxInterface.
|
overridevirtual |
Sets hull number of this robot and sends a message to update hull number to all known robots.
Implements trikNetwork::MailboxInterface.
|
overridevirtual |
Stops waiting for messages.
Implements trikNetwork::MailboxInterface.
|
signal |
Used to interrupt waiting for new message.