Some checks failed
Linux arm64 / Build (push) Has been cancelled
ajout d'un changement pour la cadence de tir Co-authored-by: Morph01 <145839520+Morph01@users.noreply.github.com> Co-authored-by: Persson-dev <sim16.prib@gmail.com> Reviewed-on: #33 Reviewed-by: Simon Pribylski <sim16.prib@gmail.com> Co-authored-by: Morph01 <thibaut6969delastreet@gmail.com> Co-committed-by: Morph01 <thibaut6969delastreet@gmail.com>
66 lines
1.4 KiB
C++
66 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "blitz/network/Connexion.h"
|
|
|
|
namespace blitz {
|
|
|
|
namespace game {
|
|
|
|
class Player;
|
|
|
|
} // namespace game
|
|
|
|
|
|
namespace server {
|
|
|
|
class Server;
|
|
|
|
struct KeepAlive {
|
|
std::uint64_t keepAliveID = 0;
|
|
std::uint64_t sendTime;
|
|
bool recievedResponse = false;
|
|
};
|
|
|
|
|
|
class ServerConnexion : public network::Connexion {
|
|
private:
|
|
Server* m_Server;
|
|
std::uint8_t m_ID;
|
|
KeepAlive m_KeepAlive;
|
|
game::Player* m_Player;
|
|
std::string m_ChatColor;
|
|
|
|
public:
|
|
ServerConnexion(Server* server, network::TCPSocket& socket, std::uint8_t id);
|
|
ServerConnexion(ServerConnexion&& move);
|
|
virtual ~ServerConnexion();
|
|
|
|
void Start();
|
|
|
|
virtual void HandlePacket(const protocol::PlayerLoginPacket* packet) override;
|
|
virtual void HandlePacket(const protocol::KeepAlivePacket* packet) override;
|
|
virtual void HandlePacket(const protocol::DisconnectPacket* packet) override;
|
|
virtual void HandlePacket(const protocol::ChatPacket* packet) override;
|
|
virtual void HandlePacket(const protocol::PlayerPositionAndRotationPacket* packet) override;
|
|
virtual void HandlePacket(const protocol::PlayerShootPacket* packet) override;
|
|
|
|
std::uint8_t GetID() const {
|
|
return m_ID;
|
|
}
|
|
|
|
virtual bool UpdateSocket();
|
|
|
|
private:
|
|
void RegisterHandlers();
|
|
void CheckKeepAlive();
|
|
void SendKeepAlive();
|
|
void InitConnection();
|
|
void InitPlayerChatColor();
|
|
void SendPlayers();
|
|
void SendGameState();
|
|
void SendServerConfig();
|
|
};
|
|
|
|
} // namespace server
|
|
} // namespace blitz
|