summaryrefslogtreecommitdiffstats
path: root/NetworkClient.hpp
blob: df2f61666bccffd42d9348151c5f9d5414d36338 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include <queue>
#include "Network.hpp"

struct ServerInfo{
    std::string version;
    int protocol = 0;
    int players_max = 0;
    int players_online = 0;
    std::vector<std::pair<std::string, std::string>> players;
    std::string description;
    double ping = 0;
    std::string favicon;
    std::string json;
};
class NetworkClient {
public:
    NetworkClient(std::string address, unsigned short port, std::string username);
    ~NetworkClient();

    void Update();

    Packet GetPacket();
    void AddPacketToQueue(Packet packet);

    static ServerInfo ServerPing(std::string address,unsigned short port);
private:
    NetworkClient (const NetworkClient&);
    NetworkClient&operator=(const NetworkClient&);
    Network m_network;
    std::queue <Packet> m_received;
    std::queue <Packet> m_toSend;
};