Network/ENet: More cleanup

This commit is contained in:
Lynix
2017-01-28 12:08:35 +01:00
parent 8fc734674d
commit c9d5f2f1ac
6 changed files with 130 additions and 137 deletions

View File

@@ -64,8 +64,6 @@ namespace Nz
void AddToDispatchQueue(ENetPeer* peer);
void RemoveFromDispatchQueue(ENetPeer* peer);
bool CheckTimeouts(ENetPeer* peer, ENetEvent* event);
bool DispatchIncomingCommands(ENetEvent* event);
bool HandleAcknowledge(ENetEvent* event, ENetPeer* peer, const ENetProtocol* command);

View File

@@ -68,8 +68,10 @@ namespace Nz
struct IncomingCommmand;
struct OutgoingCommand;
// Protocol functions
inline void ChangeState(ENetPeerState state);
bool CheckTimeouts(ENetEvent* event);
void DispatchState(ENetPeerState state);
void DispatchIncomingReliableCommands(Channel& channel);
@@ -85,6 +87,7 @@ namespace Nz
bool QueueAcknowledgement(ENetProtocol* command, UInt16 sentTime);
IncomingCommmand* QueueIncomingCommand(const ENetProtocol& command, const void* data, std::size_t dataLength, UInt32 flags, UInt32 fragmentCount);
inline void QueueOutgoingCommand(ENetProtocol& command);
void QueueOutgoingCommand(ENetProtocol& command, ENetPacketRef packet, UInt32 offset, UInt16 length);
void SetupOutgoingCommand(OutgoingCommand& outgoingCommand);

View File

@@ -37,6 +37,11 @@ namespace Nz
m_state = state;
}
inline void ENetPeer::QueueOutgoingCommand(ENetProtocol& command)
{
QueueOutgoingCommand(command, ENetPacketRef(), 0, 0);
}
}
#include <Nazara/Network/DebugOff.hpp>

View File

@@ -267,6 +267,14 @@ namespace Nz
union NAZARA_PACKED ENetProtocol
{
ENetProtocol() = default;
ENetProtocol(UInt8 command, UInt8 channel)
{
header.command = command;
header.channelID = channel;
}
ENetProtocolCommandHeader header;
ENetProtocolAcknowledge acknowledge;
ENetProtocolBandwidthLimit bandwidthLimit;