Change SendPacket with only type to not have a payload, add recv version

This commit is contained in:
baldurk
2016-08-04 11:20:37 +02:00
parent 7af08c80ee
commit 4e73f9736e
+12 -5
View File
@@ -25,6 +25,18 @@
#pragma once
inline uint32_t RecvPacket(Network::Socket *sock)
{
if(sock == NULL)
return ~0U;
uint32_t t = 0;
if(!sock->RecvDataBlocking(&t, sizeof(t)))
return ~0U;
return t;
}
template <typename PacketTypeEnum>
bool RecvPacket(Network::Socket *sock, PacketTypeEnum &type, vector<byte> &payload)
{
@@ -77,15 +89,10 @@ bool SendPacket(Network::Socket *sock, PacketTypeEnum type)
if(sock == NULL)
return false;
uint32_t payloadLength = 0;
uint32_t t = (uint32_t)type;
if(!sock->SendDataBlocking(&t, sizeof(t)))
return false;
if(!sock->SendDataBlocking(&payloadLength, sizeof(payloadLength)))
return false;
return true;
}