]> git.localhorst.tv Git - blank.git/blob - src/net/Server.hpp
b6a72a91b8b30e327f410e3eed793d11691320dd
[blank.git] / src / net / Server.hpp
1 #ifndef BLANK_NET_SERVER_HPP
2 #define BLANK_NET_SERVER_HPP
3
4 #include <list>
5 #include <SDL_net.h>
6
7
8 namespace blank {
9
10 class Connection;
11 class World;
12
13 class Server {
14
15 public:
16         struct Config {
17                 Uint16 port = 12354;
18         };
19
20 public:
21         Server(const Config &, World &);
22         ~Server();
23
24         void Handle();
25
26         void Update(int dt);
27
28 private:
29         void HandlePacket(const UDPpacket &);
30
31         Connection &GetClient(const IPaddress &);
32
33         void OnConnect(Connection &);
34         void OnDisconnect(Connection &);
35
36 private:
37         UDPsocket serv_sock;
38         UDPpacket serv_pack;
39         std::list<Connection> clients;
40
41         World &world;
42
43 };
44
45 }
46
47 #endif