/
project.cpp
50 lines (44 loc) · 1.3 KB
/
project.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
49
50
#include "Interpreter.h"
#include "Connection.h"
//TODO:
//- w finalnej wersji pouzupelniac consty
//
/**
* \brief Program mapujacy uzytkownikow do odpowiednich CI
*
* \author Przemyslaw Piorkowski <piorkowskiprzemyslaw@gmail.com>
*
*/
int main()
{
std::cout << "Map users to cell in process..." << std::endl;
Connection * conn;
Interpreter * interpreter = new Interpreter();
int dataSize;
try
{
conn = new Connection(4000, 1024);
}
catch(SocketException& e)
{
std::cout << e.what() << std::endl;
return -1;
}
/**
* Glowna petla programu odpowiedzialna za odbior i przetworzenie danych.
* W przyszlosci tutaj rodzial na watki dla kazdego przychodzacego pakietu.
*/
while(1)
{
dataSize = conn->receiveData();
std::cout << "Rozmiar odebranych danych " << dataSize << std::endl;
interpreter->loadBuffer(conn->getBuffer(), dataSize);
interpreter->interpreteData();
std::cout << "Version : " << interpreter->getVersion() << std::endl;
std::cout << "Count : " << interpreter->getMessagesCounter() << std::endl;
std::cout << "Length : " << interpreter->getLength() << std::endl;
std::cout << "Writing data to file \n" << std::endl;
interpreter->writeBufferToFile();
}
return 0;
}