From 1fe4256462826c218ed9bf171be4c07e0db33e25 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Tue, 31 Mar 2015 10:35:51 +0200 Subject: Connection::Receive(): receive Network Packet instead of SharedBuffer. Because we get a Buffer from ConnectionEvent, don't convert it to SharedBuffer and return it to Server/Client::Receive which will convert it to NetworkPacket Instead, put the Buffer directly to NetworkPacket and return it to packet processing This remove a long existing memory copy Also check the packet size directly into Connection::Receive instead of packet processing --- src/network/networkpacket.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/network/networkpacket.h') diff --git a/src/network/networkpacket.h b/src/network/networkpacket.h index 4a801b444..0afb1e7e3 100644 --- a/src/network/networkpacket.h +++ b/src/network/networkpacket.h @@ -28,11 +28,14 @@ class NetworkPacket { public: - NetworkPacket(u8 *data, u32 datasize, u16 peer_id); NetworkPacket(u16 command, u32 datasize, u16 peer_id); NetworkPacket(u16 command, u32 datasize); + NetworkPacket(): m_datasize(0), m_read_offset(0), m_command(0), + m_peer_id(0) {} ~NetworkPacket(); + void putRawPacket(u8 *data, u32 datasize, u16 peer_id); + // Getters u32 getSize() { return m_datasize; } u16 getPeerId() { return m_peer_id; } -- cgit v1.2.3