-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChannel.cpp
More file actions
28 lines (26 loc) · 775 Bytes
/
Copy pathChannel.cpp
File metadata and controls
28 lines (26 loc) · 775 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
#include "Channel.h"
Channel::Channel(QTcpSocket* _socket, QObject* parent) : QObject(parent)
{
socket = _socket;
thread = std::thread(&Channel::communicate, this);
}
Channel::~Channel()
{
thread.join();
}
void Channel::communicate()
{
while (true) {
while (!socket->waitForReadyRead(-1));
QByteArray b = socket->readAll();
QMap<QString, card*>::iterator itr;
for (itr = cards.begin(); itr != cards.end(); itr++)
if (itr.value()->getCardId().toStdString() == b.toStdString())
break;
if (itr != cards.end())
socket->write("ID is valid.");
else
socket->write("ID is not valid.");
socket->waitForBytesWritten(3000);
}
}