Converting a byte[] from java (JNI) to pass to NDK
Hi,
I'd like to use the native library for Android, and i'd like to pass some data from Java to the native library.
The data i'd like to pass is a byte array (byte[])
I define a JNI native method like so:
JNIEXPORT void JNICALL Java_demo_android_loadBalancing_PhotonNetworkingProvider_raiseEvent(JNIEnv* env, jobject obj, jbyte eventCode, jboolean reliable, jbyteArray data)
A jbyteArray can be converted into a byte array (byte*), however the Photon Cloud library works internally with a nByte type which is incompatible.
How can i properly pass a byte array into the library (to be wrapped as data inside a Hashtable that will be sent in an event) ?
Thanks
I'd like to use the native library for Android, and i'd like to pass some data from Java to the native library.
The data i'd like to pass is a byte array (byte[])
I define a JNI native method like so:
JNIEXPORT void JNICALL Java_demo_android_loadBalancing_PhotonNetworkingProvider_raiseEvent(JNIEnv* env, jobject obj, jbyte eventCode, jboolean reliable, jbyteArray data)
A jbyteArray can be converted into a byte array (byte*), however the Photon Cloud library works internally with a nByte type which is incompatible.
How can i properly pass a byte array into the library (to be wrapped as data inside a Hashtable that will be sent in an event) ?
Thanks
0
Comments
-
nByte is defined as unsigned char, which matches the C# byte on the server side, which is unsigned, too
In you JNI function just cast the byte* to nByte*.0