-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsendertoserver.h
88 lines (73 loc) · 1.66 KB
/
sendertoserver.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef SENDERTOSERVER_H
#define SENDERTOSERVER_H
#include <QObject>
#include <QThread>
#include <QDebug>
#include <QMessageBox>
#include <QMutex>
#include <QtCore>
#include <string>
#include <errno.h>
#include <signal.h>
#include <string>
#include <iostream>
#include <sstream>
#include <rcssnet/tcpsocket.hpp>
#include <rcssnet/exception.hpp>
#include <netinet/in.h>
#include <behaviors/behavior.h>
#include <behaviors/naobehavior.h>
using namespace rcss::net;
using namespace std;
extern int agentBodyType;
extern bool bResetMonitor;
extern string mHost;
extern map<string, string> namedParams;
extern string teamName;
extern int uNum;
extern string outputFile; // For optimization
extern string rsg;
class SenderToServer:public QThread
{
Q_OBJECT
public:
SenderToServer(int _agentBodyType);
~SenderToServer();
void LaunchMsgLoop();
bool Init();
void LoadParams(const string& inputsFile);
void Done();
bool SelectInput();
void PutMessage(const string& msg);
void PutMonMessage(const string& msg);
bool GetMessage(string& msg);
inline NaoBehavior* getBehavior()
{
return behavior;
}
inline int getAgentBodyType()
{
return agentBodyType;
}
inline void lockMutex()
{
mutex.lock();
}
inline void unlockMutex()
{
mutex.unlock();
}
private:
void run();
QMutex mutex;
// Variables for connecting to the server port
TCPSocket gSocket;
string gHost;
int gPort;
// Variables for connecting to the monitor port
TCPSocket mSocket;
int mPort;
NaoBehavior *behavior;
// int agentBodyType;
};
#endif // SENDERTOSERVER_H