1er commit
This commit is contained in:
56
include/game/server/ServerConnexion.h
Normal file
56
include/game/server/ServerConnexion.h
Normal 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
|
||||
Reference in New Issue
Block a user