forked from bebjorn/hockey.server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeamConnection.h
36 lines (32 loc) · 877 Bytes
/
TeamConnection.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
#include "PracticalSocket.h"
#include <string>
#define BUFLENGTH 255
#define PORT 60040
#ifndef CONNECTION
#define CONNECTION
struct Connection{//struct för att hålla reda på anslutnng
std::string adress;
unsigned short port;
bool operator==(Connection b);
Connection(){adress="";port=0;};
};
class Team{// klass för att sköta kommunikation med AI-modul
Connection connection;
UDPSocket* socket;
int lastAlive;
public:
void send(int* buf,const int bufLength);
void sendBytes(char *buf, const int bufLength);
bool fromSource(Connection source);
void command(int com[BUFLENGTH],int length);
void reportAlive();
bool isAlive();
Team(Connection source);
~Team();
};
extern Team* homeTeam;
extern Team* awayTeam;
extern UDPSocket *listeningSocket;
unsigned __stdcall recieverThread(void* param);
unsigned __stdcall checkClientsProc(void *param);
#endif