trikRuntime
|
Allows communication between robots. More...
#include <mailboxInterface.h>
Public Slots | |
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 | 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 | |
virtual bool | isConnected () const =0 |
Returns true if at least one opened mailbox connection presents at the moment. More... | |
virtual void | setHullNumber (int myHullNumber)=0 |
Sets hull number of this robot and sends a message to update hull number to all known robots. More... | |
virtual QHostAddress | serverIp () const =0 |
Returns IP of a leader robot, or empty QHostAddress if we are not connected. More... | |
virtual QHostAddress | myIp () const =0 |
Returns our IP address, or empty QHostAddress if we are not connected. More... | |
virtual void | clearQueue ()=0 |
Clears message queue. More... | |
virtual void | stopWaiting ()=0 |
Stops waiting for messages. More... | |
virtual bool | isEnabled ()=0 |
Returns true if mailbox is enabled in current configuration. More... | |
Allows communication between robots.
Each robot has its hull number (assigned in "Settings->Comm settings" in GUI), and can connect to other robot (called "leader") by IP, if they are in the same subnet (it is also can be done in "Settings->Comm settings", or from script by connect() method). Then robot can send messages to every robot that is connected to a leader (or to a robot that is connected to a robot that is connected to a leader, and so on). Recipients are identified by their hull numbers, if two or more robots in a network have the same hull number, they will all receive a message.
|
pure virtual |
Clears message queue.
Implemented in trikNetwork::Mailbox.
|
pure virtualslot |
Connects to robot by IP and port.
|
pure virtualslot |
Connects to robot by IP and uses port of local mailbox server as a port on remote robot.
|
signal |
Emitted when a mailbox either receives the first connection (connected == true) or loses the last one.
|
pure virtualslot |
Returns true if there are incoming messages. Returns immediately.
|
pure virtual |
Returns true if at least one opened mailbox connection presents at the moment.
Implemented in trikNetwork::Mailbox.
|
pure virtual |
Returns true if mailbox is enabled in current configuration.
Implemented in trikNetwork::Mailbox.
|
pure virtualslot |
Returns hull number of this robot.
|
pure virtual |
Returns our IP address, or empty QHostAddress if we are not connected.
Implemented in trikNetwork::Mailbox.
|
signal |
Emitted when new message is received from a robot with given hull number.
Note that if receive() and handler for newMessage() is used simultaneously, message will be delivered twice — first for receive(), then to handler (or handlers).
|
pure virtualslot |
Receives and returns one incoming message.
If there is already a message in a queue, returns immediately, otherwise blocks until a message is received. Note that if receive() and handler for newMessage() is used simultaneously, message will be delivered twice — first for receive(), then to handler (or handlers).
wait | - if false, doesn't wait for new messages and returns empty string if message queue is empty |
|
pure virtualslot |
Tries to get renewed IP address.
|
pure virtualslot |
Sends message to a robot with given hull number.
|
pure virtualslot |
Sends message to all known robots.
|
pure virtual |
Returns IP of a leader robot, or empty QHostAddress if we are not connected.
Implemented in trikNetwork::Mailbox.
|
pure virtual |
Sets hull number of this robot and sends a message to update hull number to all known robots.
Implemented in trikNetwork::Mailbox.
|
pure virtual |
Stops waiting for messages.
Implemented in trikNetwork::Mailbox.