Alas, Github showing a incredibly large diff. The actual changes are as minimal as possible:
the inner body of the loop do { ... } while (m_socket.Available > 0); extracted into a new private method (ReceiveSocketData).
the try-catch block around m_socket.ReceiveFrom(...) call moved outside the do { ... } while (m_socket.Available > 0); loop.
This way any socket exceptions will break the loop and properly handled (as expected).
Meanwhile the return; calls from the inner loop are no longer return from the whole Heartbeat() method as they will only return from the method ReceiveSocketData called in the loop.
The issue report is here https://github.com/lidgren/lidgren-network-gen3/issues/132#
NetPeer.Heartbeat()
method will no longer prematurely return in case of encountering an incorrect packet.Alas, Github showing a incredibly large diff. The actual changes are as minimal as possible:
the inner body of the loop
do { ... } while (m_socket.Available > 0);
extracted into a new private method (ReceiveSocketData
).the try-catch block around
m_socket.ReceiveFrom(...)
call moved outside thedo { ... } while (m_socket.Available > 0);
loop.This way any socket exceptions will break the loop and properly handled (as expected). Meanwhile the
return;
calls from the inner loop are no longer return from the wholeHeartbeat()
method as they will only return from the methodReceiveSocketData
called in the loop.Regards!