trikRuntime
trikNetwork::MailboxConnection Class Reference

One connection to a client (or server) in mailbox. Supposed to be working in a separate thread. More...

#include <mailboxConnection.h>

Inheritance diagram for trikNetwork::MailboxConnection:
Collaboration diagram for trikNetwork::MailboxConnection:

Signals

void newConnection (const QHostAddress &ip, int clientPort, int serverPort, int hullNumber)
 Emitted when "register" command is received. More...
 
void connectionInfo (const QHostAddress &ip, int port, int hullNumber)
 Emitted when remote robot sends info about other known robots ("connection" command). More...
 
void newData (const QHostAddress &ip, int port, const QByteArray &data)
 Emitted when new data message received ("data" command). More...
 
- Signals inherited from trikNetwork::Connection
void disconnected (trikNetwork::Connection *self)
 Emitted after connection becomes closed. More...
 
void connected (trikNetwork::Connection *self)
 Emitted after connection is established. More...
 

Public Member Functions

 MailboxConnection ()
 
Q_INVOKABLE void connect (const QHostAddress &targetIp, int targetPort, int myServerPort, int myHullNumber)
 Connect to given endpoint and send "register" command with our mailbox server port and hull number. More...
 
Q_INVOKABLE void sendConnectionInfo (const QHostAddress &ip, int port, int hullNumber)
 Send info about other robot: its IP, port and hull number. More...
 
Q_INVOKABLE void sendSelfInfo (int hullNumber)
 Send our hull number. Used in response for connection request. More...
 
- Public Member Functions inherited from trikNetwork::Connection
 Connection (Protocol connectionProtocol, Heartbeat useHeartbeat)
 Constructor. More...
 
bool isConnected () const
 Returns true if socket is opened or false otherwise. More...
 
bool isValid () const
 Checks if socket is valid or not Attention!!! Hot fix for NTI contest. More...
 
QHostAddress peerAddress () const
 Returns peer address of a connection, if it is open, or empty QHostAddress if connection is not established yet. More...
 
int peerPort () const
 Returns peer port of a connection, if it is open, or -1 if connection is not established yet. More...
 
Q_INVOKABLE void init (qintptr socketDescriptor)
 Creates socket and initializes incoming connection, shall be called when Connection is already in its own thread. More...
 
Q_INVOKABLE void send (const QByteArray &data)
 Sends given byte array to peer. More...
 

Additional Inherited Members

- Protected Member Functions inherited from trikNetwork::Connection
void init (const QHostAddress &ip, int port)
 Creates socket and initializes outgoing connection, shall be called when Connection is already in its own thread. More...
 

Detailed Description

One connection to a client (or server) in mailbox. Supposed to be working in a separate thread.

Constructor & Destructor Documentation

MailboxConnection::MailboxConnection ( )

Member Function Documentation

void MailboxConnection::connect ( const QHostAddress &  targetIp,
int  targetPort,
int  myServerPort,
int  myHullNumber 
)

Connect to given endpoint and send "register" command with our mailbox server port and hull number.

void trikNetwork::MailboxConnection::connectionInfo ( const QHostAddress &  ip,
int  port,
int  hullNumber 
)
signal

Emitted when remote robot sends info about other known robots ("connection" command).

void trikNetwork::MailboxConnection::newConnection ( const QHostAddress &  ip,
int  clientPort,
int  serverPort,
int  hullNumber 
)
signal

Emitted when "register" command is received.

Parameters
ip- remote robot IP.
clientPort- remote robot client port (peer port), for reuse of this new connection.
serverPort- remote robot mailbox server port.
hullNumber- remote robot hull number.
void trikNetwork::MailboxConnection::newData ( const QHostAddress &  ip,
int  port,
const QByteArray &  data 
)
signal

Emitted when new data message received ("data" command).

void MailboxConnection::sendConnectionInfo ( const QHostAddress &  ip,
int  port,
int  hullNumber 
)

Send info about other robot: its IP, port and hull number.

void MailboxConnection::sendSelfInfo ( int  hullNumber)

Send our hull number. Used in response for connection request.


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