Protocol 1.7: Added status ping handling.
This commit is contained in:
parent
f490d3d1e7
commit
feaea31b78
@ -103,6 +103,7 @@ void cProtocol172::HandlePacket(UInt32 a_PacketType, UInt32 a_RemainingBytes)
|
|||||||
switch (a_PacketType)
|
switch (a_PacketType)
|
||||||
{
|
{
|
||||||
case 0x00: HandlePacketStatusRequest(a_RemainingBytes); return;
|
case 0x00: HandlePacketStatusRequest(a_RemainingBytes); return;
|
||||||
|
case 0x01: HandlePacketStatusPing (a_RemainingBytes); return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -157,6 +158,30 @@ void cProtocol172::HandlePacketStatusRequest(UInt32 a_RemainingBytes)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cProtocol172::HandlePacketStatusPing(UInt32 a_RemainingBytes)
|
||||||
|
{
|
||||||
|
ASSERT(a_RemainingBytes == 8);
|
||||||
|
if (a_RemainingBytes != 8)
|
||||||
|
{
|
||||||
|
m_Client->PacketError(0x01);
|
||||||
|
m_ReceivedData.SkipRead(a_RemainingBytes);
|
||||||
|
m_ReceivedData.CommitRead();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Int64 Timestamp;
|
||||||
|
m_ReceivedData.ReadBEInt64(Timestamp);
|
||||||
|
m_ReceivedData.CommitRead();
|
||||||
|
|
||||||
|
cByteBuffer Packet(18);
|
||||||
|
Packet.WriteVarInt(0x01);
|
||||||
|
Packet.WriteBEInt64(Timestamp);
|
||||||
|
WritePacket(Packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cProtocol172::WritePacket(cByteBuffer & a_Packet)
|
void cProtocol172::WritePacket(cByteBuffer & a_Packet)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CSPacket);
|
cCSLock Lock(m_CSPacket);
|
||||||
|
@ -58,7 +58,9 @@ protected:
|
|||||||
/// Reads and handles the packet. The packet length and type have already been read.
|
/// Reads and handles the packet. The packet length and type have already been read.
|
||||||
void HandlePacket(UInt32 a_PacketType, UInt32 a_RemainingBytes);
|
void HandlePacket(UInt32 a_PacketType, UInt32 a_RemainingBytes);
|
||||||
|
|
||||||
|
// Packet handlers while in the Status state (m_State == 1)
|
||||||
void HandlePacketStatusRequest(UInt32 a_RemainingBytes);
|
void HandlePacketStatusRequest(UInt32 a_RemainingBytes);
|
||||||
|
void HandlePacketStatusPing (UInt32 a_RemainingBytes);
|
||||||
|
|
||||||
/// Writes an entire packet into the output stream. a_Packet is expected to start with the packet type; data length is prepended here.
|
/// Writes an entire packet into the output stream. a_Packet is expected to start with the packet type; data length is prepended here.
|
||||||
void WritePacket(cByteBuffer & a_Packet);
|
void WritePacket(cByteBuffer & a_Packet);
|
||||||
|
Loading…
Reference in New Issue
Block a user