author | terom |
Mon, 10 Nov 2008 18:21:23 +0000 | |
branch | no-netsession |
changeset 32 | 2ff929186c90 |
parent 24 | b81cb670e6b2 |
child 36 | 785d220fc6b7 |
permissions | -rw-r--r-- |
5 | 1 |
#ifndef NETWORKSERVER_HH |
2 |
#define NETWORKSERVER_HH |
|
3 |
||
6 | 4 |
#include "Network.hh" |
5 |
#include "GameState.hh" |
|
32 | 6 |
#include "NetworkTCP.hh" |
7 |
#include "NetworkUDP.hh" |
|
6 | 8 |
|
5 | 9 |
#include <list> |
6 | 10 |
#include <map> |
11 |
#include <ClanLib/core.h> |
|
5 | 12 |
|
6 | 13 |
// forward-declare |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
14 |
class NetworkServerPlayer; |
6 | 15 |
|
21 | 16 |
class NetworkServer : public NetworkCore { |
24 | 17 |
friend class NetworkServerPlayer; |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
18 |
|
24 | 19 |
private: |
32 | 20 |
NetworkTCPServer tcp_server; |
21 |
NetworkUDP udp; |
|
22 |
||
24 | 23 |
uint16_t pid_pool; |
32 | 24 |
|
25 |
std::map<NetworkAddress, NetworkServerPlayer*> players; |
|
5 | 26 |
|
24 | 27 |
public: |
32 | 28 |
NetworkServer (GameState &state, const NetworkAddress &listen_addr); |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
29 |
|
24 | 30 |
private: |
32 | 31 |
void on_client (NetworkTCPTransport *client); |
32 |
void on_packet_udp (const NetworkPacket &pkt, const NetworkAddress &src); |
|
5 | 33 |
}; |
34 |
||
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
35 |
class NetworkServerPlayer : public RemotePlayer { |
24 | 36 |
private: |
37 |
NetworkServer &server; |
|
32 | 38 |
NetworkTCPTransport *tcp; |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
39 |
|
24 | 40 |
CL_SlotContainer slots; |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
41 |
|
24 | 42 |
uint16_t pid; |
43 |
||
44 |
public: |
|
32 | 45 |
NetworkServerPlayer (NetworkServer &server, NetworkTCPTransport *tcp, uint16_t pid); |
22
b70d30e1b0fe
all the network code is now there, although it doesn't quite work
terom
parents:
21
diff
changeset
|
46 |
|
24 | 47 |
private: |
32 | 48 |
void on_disconnected (void); |
49 |
void on_packet_tcp (const NetworkPacket &pkt); |
|
50 |
||
51 |
void on_move (const NetworkPacket &pkt); |
|
24 | 52 |
|
53 |
void send_position_update (void); |
|
5 | 54 |
}; |
55 |
||
56 |
#endif |