-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathserver.cpp
More file actions
39 lines (28 loc) · 983 Bytes
/
Copy pathserver.cpp
File metadata and controls
39 lines (28 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "dialog.h"
#include "server.h"
Server::Server(QObject *parent) :
QTcpServer(parent)
{
/* get current dialog object */
m_dialog = dynamic_cast<Dialog *>(parent);
}
Server::~Server()
{
}
void Server::incomingConnection(int sockDesc)
{
m_socketList.append(sockDesc);
serverThread *thread = new serverThread(sockDesc);
m_dialog->showConnection(sockDesc);
connect(thread, SIGNAL(disconnectTCP(int)), this, SLOT(clientDisconnected(int)));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
connect(thread, SIGNAL(dataReady(const QString&, const QByteArray&)),
m_dialog, SLOT(recvData(const QString&, const QByteArray&)));
connect(m_dialog, SIGNAL(sendData(int, const QByteArray&)),
thread, SLOT(sendDataSlot(int, const QByteArray&)));
thread->start();
}
void Server::clientDisconnected(int sockDesc)
{
m_dialog->showDisconnection(sockDesc);
}