Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
listenserver.cpp
Go to the documentation of this file.
1 #include "listenserver.h"
2 #include "client.h"
3 
4 #include <QSslSocket>
5 
11 ListenServer::ListenServer(quint16 port, QObject *parent)
12  : QObject(parent)
13  , _server(this)
14 {
15  if (!_server.listen(QHostAddress::AnyIPv4, port) || !_server.isListening())
16  qFatal("Cannot bind to TCP port %d (incoming SSL clients)", int(port));
17  connect(&_server, &SslServer::newConnection, this, &ListenServer::newClientConnection);
18 }
19 
21 {
22  _server.close();
23 }
24 
25 /*
26  * Slots
27  */
28 
34 {
35  QTcpSocket* sock;
36  while ((sock = _server.nextPendingConnection()) != nullptr) {
37  auto* client = new Client(sock); // TODO: what happens with disconnected clients
38  emit newClient(client);
39  }
40 }
~ListenServer() override
SslServer _server
Definition: listenserver.h:18
void newClientConnection()
Handle new client connection.
Definition: client.h:23
ListenServer(quint16 port, QObject *parent)
Initialize listenServer to listen on specific port.
void newClient(Client *client)