-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReceptionThread.cpp
More file actions
52 lines (46 loc) · 1.02 KB
/
ReceptionThread.cpp
File metadata and controls
52 lines (46 loc) · 1.02 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "ReceptionThread.h"
#include "FenPrincipale.h"
ReceptionThread::ReceptionThread(FenPrincipale& parent)
: mParent(parent)
, mMutex(parent.getComMutex())
, mClient(parent.getClient())
{
setParent(0);
moveToThread(this);
}
ReceptionThread::~ReceptionThread()
{
delete mMutex;
}
void ReceptionThread::run() {
while (1)
{
while (auto msg = mClient.poll())
{
if (msg->is<Network::Messages::Connection>())
{
auto connection = msg->as<Network::Messages::Connection>();
if (connection->result == Network::Messages::Connection::Result::Success)
{
//Gestion connexion
}
else
{
break;
}
}
else if (msg->is<Network::Messages::UserData>())
{
auto userdata = msg->as<Network::Messages::UserData>();
mMutex->lock();
mParent.getReceivingQueue()->push_back(*userdata);
mMutex->unlock();
}
else if (msg->is<Network::Messages::Disconnection>())
{
auto disconnection = msg->as<Network::Messages::Disconnection>();
//Gestion de déconnexion
}
}
}
}