mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-27 17:28:41 +00:00
Connection::Receive(): receive Network Packet instead of SharedBuffer<u8>.
Because we get a Buffer<u8> from ConnectionEvent, don't convert it to SharedBuffer<u8> and return it to Server/Client::Receive which will convert it to NetworkPacket Instead, put the Buffer<u8> 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
This commit is contained in:
parent
ab77bf98ee
commit
1fe4256462
9 changed files with 104 additions and 98 deletions
|
@ -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; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue