-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanageStation.cpp
48 lines (44 loc) · 1.22 KB
/
manageStation.cpp
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
#include "manageStation.h"
using namespace std;
ManageStation::ManageStation( HelloModule * he)
{
hello = he;
}
void ManageStation::addStation(Station s)
{
liste.append(s);
}
Station ManageStation::getStation(int index)
{
return liste.at(index);
}
int ManageStation::getNbStation()
{
return liste.size();
}
void ManageStation::processMessage(QByteArray& data)
{
// exctraction des information
cout << " traitement du message recu" << endl;
QStringList parametre;
QString chaine(data.data());
parametre = chaine.split('#');
cout << "[ip]:" << parametre[0].toStdString() << endl;
cout << "[port]:" << parametre[1].toStdString() << endl;
cout << "[etat]:" << parametre[2].toStdString() << endl;
// ordre des information: check#info1#info2#....#
// check if station already exist
for (int i = 0; i < liste.size(); ++i)
{
// cout << "parcour " << i << parametre[0].toStdString() << endl;
if(liste.at(i).ip.toString().compare(parametre[0])==0)
{
cout << "existe deja" <<endl;
return ;
}
}
addStation(Station(QHostAddress(parametre[0]),parametre[1].toInt(),parametre[2].toInt()));
hello->SendHelloIP(QString(parametre[0]));
//emit sendHelloIP()
emit updateListeEvent();
}