Fail writePacket if enet_peer_send returns -1

This commit is contained in:
Cameron Gutman 2016-03-07 12:54:06 -08:00
parent 94ee24ea11
commit ceef00b79a

View File

@ -99,9 +99,16 @@ Java_com_limelight_nvstream_enet_EnetConnection_writePacket(JNIEnv *env, jobject
packet = enet_packet_create(dataPtr, length, packetFlags);
if (packet != NULL) {
// Send the message to the peer
enet_peer_send(LONG_TO_PEER(peer), 0, packet);
enet_host_flush(LONG_TO_CLIENT(client));
ret = JNI_TRUE;
if (enet_peer_send(LONG_TO_PEER(peer), 0, packet) < 0) {
// This can fail if the peer has been disconnected
enet_packet_destroy(packet);
ret = JNI_FALSE;
}
else {
// Force the client to send the packet now
enet_host_flush(LONG_TO_CLIENT(client));
ret = JNI_TRUE;
}
}
else {
ret = JNI_FALSE;