Minor update to control api (and JNI). zts_start, zts_stop return int

This commit is contained in:
Joseph Henry
2019-02-28 15:47:49 -08:00
parent 916b9605a3
commit 0afa8e41fa
2 changed files with 15 additions and 4 deletions

View File

@@ -90,6 +90,16 @@ public class ZeroTier
public static int EVENT_PEER_RELAY = 97;
public static int EVENT_PEER_UNREACHABLE = 98;
//////////////////////////////////////////////////////////////////////////////
// ZeroTier Constants //
//////////////////////////////////////////////////////////////////////////////
public static int ZT_MAX_PEER_NETWORK_PATHS = 16;
//////////////////////////////////////////////////////////////////////////////
// Socket API Constants //
//////////////////////////////////////////////////////////////////////////////
// Socket protocol types
public static int SOCK_STREAM = 0x00000001;
public static int SOCK_DGRAM = 0x00000002;
@@ -166,8 +176,8 @@ public class ZeroTier
// ZeroTier Service Controls //
//////////////////////////////////////////////////////////////////////////////
public static native void start(String path, ZeroTierEventListener callbackClass, int port);
public static native void stop();
public static native int start(String path, ZeroTierEventListener callbackClass, int port);
public static native int stop();
public static native int join(long nwid);
public static native int leave(long nwid);
public static native long get_node_id();

View File

@@ -576,7 +576,7 @@ zts_err_t zts_start(const char *path, void (*callback)(struct zts_callback_msg*)
}
#ifdef SDK_JNI
JNIEXPORT void JNICALL Java_com_zerotier_libzt_ZeroTier_start(
JNIEXPORT int JNICALL Java_com_zerotier_libzt_ZeroTier_start(
JNIEnv *env, jobject thisObj, jstring path, jobject callback, jint port)
{
if (!path) {
@@ -595,8 +595,9 @@ JNIEXPORT void JNICALL Java_com_zerotier_libzt_ZeroTier_start(
objRef = env->NewGlobalRef(callback); // Reference used for later calls
_userCallbackMethodRef = eventListenerCallbackMethod;
const char* utf_string = env->GetStringUTFChars(path, NULL);
zts_start(utf_string, NULL, port); // using _userCallbackMethodRef
int retval = zts_start(utf_string, NULL, port); // using _userCallbackMethodRef
env->ReleaseStringUTFChars(path, utf_string);
return retval;
}
#endif