56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
#pragma once
|
|
|
|
/**
|
|
* \file KeepAlivePacket.h
|
|
* \brief File containing the blitz::protocol::KeepAlivePacket class
|
|
*/
|
|
|
|
#include "blitz/protocol/VarInt.h"
|
|
#include "blitz/protocol/Protocol.h"
|
|
|
|
namespace blitz {
|
|
namespace protocol {
|
|
|
|
/**
|
|
* \class KeepAlivePacket
|
|
* \brief Packet sent to measure the health of a connexion. \n
|
|
* The client must respond with the same alive ID. Else, the connexion will be closed. \n
|
|
* %Packet structure :
|
|
* | PacketType |
|
|
* |------------------------|
|
|
* | PacketType::KeepAlive |
|
|
*
|
|
* | Field Name | Field Type | Notes |
|
|
* |--------------------|---------------|---------------------------------------------------------------------------|
|
|
* | Keep Alive ID | VarInt | The server generates a random ID, the client must respond with the same |
|
|
*
|
|
*/
|
|
class KeepAlivePacket : public Packet {
|
|
private:
|
|
VarInt m_AliveID;
|
|
|
|
public:
|
|
KeepAlivePacket() {}
|
|
KeepAlivePacket(std::uint64_t aliveID) : m_AliveID(aliveID) {}
|
|
virtual ~KeepAlivePacket() {}
|
|
|
|
virtual DataBuffer Serialize(bool packetID = true) const;
|
|
virtual void Deserialize(DataBuffer& data);
|
|
virtual void Dispatch(PacketHandler* handler) const;
|
|
|
|
/**
|
|
* \brief Getter of the alive ID
|
|
* \return The alive ID
|
|
*/
|
|
std::uint64_t GetAliveID() const {
|
|
return m_AliveID.GetValue();
|
|
}
|
|
|
|
virtual PacketType GetType() const {
|
|
return PacketType::KeepAlive;
|
|
}
|
|
};
|
|
|
|
} // namespace protocol
|
|
} // namespace blitz
|