summaryrefslogtreecommitdiffstats
path: root/src/NetworkClient.hpp
blob: 2bcbd9fb4587284d363f96d2270303b07bc5588f (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
#pragma once

#include <memory>
#include <queue>
#include <string>
#include <chrono>

class Network;
struct Packet;
enum ConnectionState : unsigned char;

class NetworkClient {
    std::unique_ptr<Network> network;
	std::queue <std::shared_ptr<Packet>> toSend;
	std::queue <std::shared_ptr<Packet>> toReceive;
	ConnectionState state;
    int compressionThreshold = -1;
    std::chrono::steady_clock::time_point timeOfLastKeepAlivePacket;
public:
	NetworkClient(std::string address, unsigned short port, std::string username);
	~NetworkClient();

	std::shared_ptr <Packet> ReceivePacket();
	void SendPacket(std::shared_ptr<Packet> packet);

    void UpdatePacket();
};