mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Make Connection::Receive return the data via a SharedBuffer reference, so the caller doesn't have to choose the right buffer size in advance.
Conflicts: src/test.cpp
This commit is contained in:
parent
28660b4c1a
commit
1c98ec94da
5 changed files with 33 additions and 35 deletions
|
@ -1577,7 +1577,7 @@ void Connection::Disconnect()
|
|||
putCommand(c);
|
||||
}
|
||||
|
||||
u32 Connection::Receive(u16 &peer_id, u8 *data, u32 datasize)
|
||||
u32 Connection::Receive(u16 &peer_id, SharedBuffer<u8> &data)
|
||||
{
|
||||
for(;;){
|
||||
ConnectionEvent e = waitEvent(m_bc_receive_timeout);
|
||||
|
@ -1589,7 +1589,7 @@ u32 Connection::Receive(u16 &peer_id, u8 *data, u32 datasize)
|
|||
throw NoIncomingDataException("No incoming data");
|
||||
case CONNEVENT_DATA_RECEIVED:
|
||||
peer_id = e.peer_id;
|
||||
memcpy(data, *e.data, e.data.getSize());
|
||||
data = SharedBuffer<u8>(e.data);
|
||||
return e.data.getSize();
|
||||
case CONNEVENT_PEER_ADDED: {
|
||||
Peer tmp(e.peer_id, e.address);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue