ENet wrapper properly detect disconnect on poll
Now PacketPeerUDP.get_available_packet_count() return -1 if the socket is in error state.
This commit is contained in:
parent
d3108985e0
commit
7de28be764
@ -61,7 +61,7 @@ int PacketPeerUDPPosix::get_available_packet_count() const {
|
|||||||
|
|
||||||
Error err = const_cast<PacketPeerUDPPosix *>(this)->_poll(false);
|
Error err = const_cast<PacketPeerUDPPosix *>(this)->_poll(false);
|
||||||
if (err != OK)
|
if (err != OK)
|
||||||
return 0;
|
return -1;
|
||||||
|
|
||||||
return queue_count;
|
return queue_count;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ int PacketPeerUDPWinsock::get_available_packet_count() const {
|
|||||||
|
|
||||||
Error err = const_cast<PacketPeerUDPWinsock *>(this)->_poll(false);
|
Error err = const_cast<PacketPeerUDPWinsock *>(this)->_poll(false);
|
||||||
if (err != OK)
|
if (err != OK)
|
||||||
return 0;
|
return -1;
|
||||||
|
|
||||||
return queue_count;
|
return queue_count;
|
||||||
}
|
}
|
||||||
|
5
thirdparty/enet/godot.cpp
vendored
5
thirdparty/enet/godot.cpp
vendored
@ -168,8 +168,9 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf
|
|||||||
|
|
||||||
PacketPeerUDP *sock = (PacketPeerUDP *)socket;
|
PacketPeerUDP *sock = (PacketPeerUDP *)socket;
|
||||||
|
|
||||||
if (sock->get_available_packet_count() == 0) {
|
int pc = sock->get_available_packet_count();
|
||||||
return 0;
|
if (pc < 1) {
|
||||||
|
return pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t *buffer;
|
const uint8_t *buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user