Abstract class that serves one client of TrikServer.
More...
#include <connection.h>
|
| | 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...
|
| |
|
| 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...
|
| |
Abstract class that serves one client of TrikServer.
Meant to work in separate thread. Creates its own socket and handles all incoming messages.
Constructor.
- Parameters
-
| connectionProtocol | - protocol used by this connection. |
| useHeartbeat | - use or don't use heartbeat protocol option. |
Emitted after connection is established.
Emitted after connection becomes closed.
| void Connection::init |
( |
qintptr |
socketDescriptor | ) |
|
Creates socket and initializes incoming connection, shall be called when Connection is already in its own thread.
- Parameters
-
| socketDescriptor | - native socket descriptor. |
| void Connection::init |
( |
const QHostAddress & |
ip, |
|
|
int |
port |
|
) |
| |
|
protected |
Creates socket and initializes outgoing connection, shall be called when Connection is already in its own thread.
- Parameters
-
| ip | - target ip address. |
| port | - target port. |
| bool Connection::isConnected |
( |
| ) |
const |
Returns true if socket is opened or false otherwise.
| bool Connection::isValid |
( |
| ) |
const |
Checks if socket is valid or not Attention!!! Hot fix for NTI contest.
There are a lot of incorrect interaction between threads, this dirty fix checks that current connection exists. For example, sometimes thread and connection are added/deleted to mConnections in TrikServer, but actually they are not added/deleted.
| QHostAddress Connection::peerAddress |
( |
| ) |
const |
Returns peer address of a connection, if it is open, or empty QHostAddress if connection is not established yet.
| int Connection::peerPort |
( |
| ) |
const |
Returns peer port of a connection, if it is open, or -1 if connection is not established yet.
| void Connection::send |
( |
const QByteArray & |
data | ) |
|
Sends given byte array to peer.
Reset keepalive timer to avoid spamming with keepalive packets.
The documentation for this class was generated from the following files: