summaryrefslogblamecommitdiffstats
path: root/src/NetworkClient.hpp
blob: a26c262aa098e1c61d2d490ecde18ffe2af0c6a5 (plain) (tree)
1
2
3
4
5
6
7
8
9

            
                 
                
                
 
                      
                    
 
                     
                        

                                                       
                              
                                  
                                                                    
       
                                                                                      
                         
 

                                                        

                        
 
#pragma once

#include <thread>
#include <queue>
#include <mutex>

#include "Network.hpp"
#include "Event.hpp"

class NetworkClient {
	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();
};