Working ENet with new common jar and modified ENet library

This commit is contained in:
Cameron Gutman 2016-03-06 15:55:33 -08:00
parent 06822ad385
commit 44a0ae86d2
5 changed files with 8 additions and 4 deletions

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "app/src/main/jni/jnienet/enet"]
path = app/src/main/jni/jnienet/enet
url = https://github.com/lsalzman/enet.git
url = https://github.com/cgutman/enet.git

Binary file not shown.

Binary file not shown.

@ -1 +1 @@
Subproject commit 4d1067179bd933c6bf6465c406243472128fa34b
Subproject commit 4f7ef11c2352dc53539d1ff93887ef637a6c2e2f

View File

@ -30,7 +30,7 @@ Java_com_limelight_nvstream_enet_EnetConnection_connectToPeer(JNIEnv *env, jobje
// Initialize the ENet address
addrStr = (*env)->GetStringUTFChars(env, address, 0);
enet_address_set_host(&enetAddress, addrStr);
enetAddress.port = port;
enet_address_set_port(&enetAddress, port);
(*env)->ReleaseStringUTFChars(env, address, addrStr);
// Start the connection
@ -47,6 +47,9 @@ Java_com_limelight_nvstream_enet_EnetConnection_connectToPeer(JNIEnv *env, jobje
// Ensure the connect verify ACK is sent immediately
enet_host_flush(LONG_TO_CLIENT(client));
// Set the max peer timeout to 10 seconds
enet_peer_timeout(peer, ENET_PEER_TIMEOUT_LIMIT, ENET_PEER_TIMEOUT_MINIMUM, 10000);
return PEER_TO_LONG(peer);
}
@ -68,7 +71,8 @@ Java_com_limelight_nvstream_enet_EnetConnection_readPacket(JNIEnv *env, jobject
// Check that the packet isn't too large
if (event.packet->dataLength > length) {
return -1;
enet_packet_destroy(event.packet);
return event.packet->dataLength;
}
// Copy the packet data into the caller's buffer