]> git.localhorst.tv Git - blank.git/blob - src/net/Server.hpp
send player updates from client to server
[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 ClientConnection;
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         UDPsocket &GetSocket() noexcept { return serv_sock; }
29         UDPpacket &GetPacket() noexcept { return serv_pack; }
30
31         World &GetWorld() noexcept { return world; }
32
33 private:
34         void HandlePacket(const UDPpacket &);
35
36         ClientConnection &GetClient(const IPaddress &);
37
38 private:
39         UDPsocket serv_sock;
40         UDPpacket serv_pack;
41         std::list<ClientConnection> clients;
42
43         World &world;
44
45 };
46
47 }
48
49 #endif