Server that can handle multiple clients. Actual work is done in separate threads by Connection objects.
More...
#include <trikServer.h>
|
void | sendMessage (const QString &message) |
| Broadcasts message across all opened connections. More...
|
|
Server that can handle multiple clients. Actual work is done in separate threads by Connection objects.
TrikServer::TrikServer |
( |
const std::function< Connection *()> & |
connectionFactory | ) |
|
|
explicit |
Constructor.
- Parameters
-
connectionFactory | - function that provides actual connection objects. |
TrikServer::~TrikServer |
( |
| ) |
|
|
override |
int TrikServer::activeConnections |
( |
| ) |
const |
Returns number of connections currently opened.
void trikNetwork::TrikServer::connected |
( |
| ) |
|
|
signal |
Emitted when we get the first connection established.
Connection * TrikServer::connection |
( |
const QHostAddress & |
ip, |
|
|
int |
port |
|
) |
| const |
|
protected |
Searches connection to given IP and port in a list of all open connections.
Note that if connection is added by startConnection() call but not finished to open yet, it will not be found.
Connection * TrikServer::connection |
( |
const QHostAddress & |
ip | ) |
const |
|
protected |
Searches connection to given IP and any port in a list of all open connections.
Will return arbitrary matching connection if there are more than one connection with this IP. Note that if connection is added by startConnection() call but not finished to open yet, it will not be found.
void trikNetwork::TrikServer::disconnected |
( |
| ) |
|
|
signal |
Emitted when the last connection closes.
void TrikServer::incomingConnection |
( |
qintptr |
socketDescriptor | ) |
|
|
overrideprotected |
void TrikServer::sendMessage |
( |
const QString & |
message | ) |
|
|
slot |
Broadcasts message across all opened connections.
void TrikServer::startConnection |
( |
Connection * |
connectionWorker | ) |
|
|
protected |
Launches given connection in a separate thread. Takes ownership over connectionWorker object.
- Todo:
- : Emit "connected" signal only when socket is actually connected.
void TrikServer::startServer |
( |
quint16 |
port | ) |
|
Starts listening given port on all network interfaces.
The documentation for this class was generated from the following files: