1er commit

This commit is contained in:
2021-08-21 10:14:47 +02:00
commit a99ecf7c2d
99 changed files with 66605 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
#pragma once
#include "network/TCPSocket.h"
#include "protocol/PacketHandler.h"
#include "protocol/PacketDispatcher.h"
#include "game/Player.h"
#include "game/Connexion.h"
namespace td{
namespace server{
class Server;
struct KeepAlive
{
std::uint64_t keepAliveID = 0;
std::uint64_t sendTime;
bool recievedResponse = false;
};
class ServerConnexion : public protocol::Connexion{
private:
Server* m_Server = nullptr;
std::uint8_t m_ID;
KeepAlive m_KeepAlive;
game::Player* m_Player;
public:
ServerConnexion();
ServerConnexion(network::TCPSocket& socket, std::uint8_t id);
ServerConnexion(ServerConnexion&& move);
virtual ~ServerConnexion();
void setServer(Server* server);
virtual void HandlePacket(protocol::PlayerLoginPacket* packet);
virtual void HandlePacket(protocol::KeepAlivePacket* packet);
virtual void HandlePacket(protocol::SelectTeamPacket* packet);
virtual void HandlePacket(protocol::DisconnectPacket* packet);
std::uint8_t getID() const{return m_ID;}
const game::Player* getPlayer() const{return m_Player;}
game::Player* getPlayer() {return m_Player;}
virtual bool updateSocket();
REMOVE_COPY(ServerConnexion);
private:
void registerHandlers();
void checkKeepAlive();
void sendKeepAlive();
void initConnection();
};
} // namespace server
} // namespace td