use new ZT_Node_Callbacks struct in JNI

This commit is contained in:
Grant Limberg 2016-11-22 13:03:36 -08:00
parent 9892f7bb47
commit 3c5e28a27d

View File

@ -56,7 +56,11 @@ namespace {
, eventListener(NULL)
, frameListener(NULL)
, configListener(NULL)
{}
, callbacks(NULL)
{
callbacks = (ZT_Node_Callbacks*)malloc(sizeof(ZT_Node_Callbacks));
memset(callbacks, 0, sizeof(ZT_Node_Callbacks));
}
~JniRef()
{
@ -69,6 +73,9 @@ namespace {
env->DeleteGlobalRef(eventListener);
env->DeleteGlobalRef(frameListener);
env->DeleteGlobalRef(configListener);
free(callbacks);
callbacks = NULL;
}
uint64_t id;
@ -83,6 +90,8 @@ namespace {
jobject eventListener;
jobject frameListener;
jobject configListener;
ZT_Node_Callbacks *callbacks;
};
@ -602,17 +611,18 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init(
}
ref->eventListener = env->NewGlobalRef(tmp);
ref->callbacks->dataStoreGetFunction = &DataStoreGetFunction;
ref->callbacks->dataStorePutFunction = &DataStorePutFunction;
ref->callbacks->wirePacketSendFunction = &WirePacketSendFunction;
ref->callbacks->virtualNetworkFrameFunction = &VirtualNetworkFrameFunctionCallback;
ref->callbacks->virtualNetworkConfigFunction = &VirtualNetworkConfigFunctionCallback;
ref->callbacks->eventCallback = &EventCallback;
ZT_ResultCode rc = ZT_Node_new(
&node,
ref,
(uint64_t)now,
&DataStoreGetFunction,
&DataStorePutFunction,
&WirePacketSendFunction,
&VirtualNetworkFrameFunctionCallback,
&VirtualNetworkConfigFunctionCallback,
NULL,
&EventCallback);
ref->callbacks,
(uint64_t)now);
if(rc != ZT_RESULT_OK)
{