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