trikRuntime
trikNetwork::Mailbox Class Reference

Implementation of mailboxes system. More...

#include <mailbox.h>

Inheritance diagram for trikNetwork::Mailbox:
Collaboration diagram for trikNetwork::Mailbox:

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...
 

Detailed Description

Implementation of mailboxes system.

Constructor & Destructor Documentation

Mailbox::Mailbox ( int  port)

Constructor.

Parameters
port- port for mailbox server.
Mailbox::Mailbox ( const trikKernel::Configurer configurer)

Constructor.

Parameters
configurer- configurer object that contains preparsed XML config.
Mailbox::~Mailbox ( )
override

Member Function Documentation

void Mailbox::clearQueue ( )
overridevirtual

Clears message queue.

Implements trikNetwork::MailboxInterface.

void Mailbox::connect ( const QString &  ip,
int  port 
)
overrideslot
void Mailbox::connect ( const QString &  ip)
overrideslot
bool Mailbox::hasMessages ( )
overrideslot
bool Mailbox::isConnected ( ) const
overridevirtual

Returns true if at least one opened mailbox connection presents at the moment.

Implements trikNetwork::MailboxInterface.

bool Mailbox::isEnabled ( )
overridevirtual

Returns true if mailbox is enabled in current configuration.

Implements trikNetwork::MailboxInterface.

int Mailbox::myHullNumber ( ) const
overrideslot
QHostAddress Mailbox::myIp ( ) const
overridevirtual

Returns our IP address, or empty QHostAddress if we are not connected.

Implements trikNetwork::MailboxInterface.

QString Mailbox::receive ( bool  wait = true)
overrideslot
void Mailbox::renewIp ( )
overrideslot
void Mailbox::send ( int  hullNumber,
const QString &  message 
)
overrideslot
void Mailbox::send ( const QString &  message)
overrideslot
QHostAddress Mailbox::serverIp ( ) const
overridevirtual

Returns IP of a leader robot, or empty QHostAddress if we are not connected.

Implements trikNetwork::MailboxInterface.

void Mailbox::setHullNumber ( int  myHullNumber)
overridevirtual

Sets hull number of this robot and sends a message to update hull number to all known robots.

Implements trikNetwork::MailboxInterface.

void Mailbox::stopWaiting ( )
overridevirtual

Stops waiting for messages.

Implements trikNetwork::MailboxInterface.

void trikNetwork::Mailbox::stopWaitingSignal ( )
signal

Used to interrupt waiting for new message.


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