]> git.localhorst.tv Git - blank.git/blob - src/net/Server.hpp
6a1e9969bea693cbead97fafb5b9ec73d0cb7348
[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         void HandleLogin(Connection &client, const UDPpacket &);
37
38 private:
39         UDPsocket serv_sock;
40         UDPpacket serv_pack;
41         std::list<Connection> clients;
42
43         World &world;
44
45 };
46
47 }
48
49 #endif