mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-07-07 21:41:43 -07:00
add PeerRole.fromInt
This commit is contained in:
parent
7c5f256d4a
commit
056cef7292
4 changed files with 36 additions and 29 deletions
|
@ -126,24 +126,12 @@ jobject createEvent(JNIEnv *env, ZT_Event event)
|
|||
|
||||
jobject createPeerRole(JNIEnv *env, ZT_PeerRole role)
|
||||
{
|
||||
jobject peerRoleObject = NULL;
|
||||
|
||||
jfieldID field;
|
||||
switch(role)
|
||||
{
|
||||
case ZT_PEER_ROLE_LEAF:
|
||||
field = PeerRole_PEER_ROLE_LEAF_field;
|
||||
break;
|
||||
case ZT_PEER_ROLE_MOON:
|
||||
field = PeerRole_PEER_ROLE_MOON_field;
|
||||
break;
|
||||
case ZT_PEER_ROLE_PLANET:
|
||||
field = PeerRole_PEER_ROLE_PLANET_field;
|
||||
break;
|
||||
jobject peerRoleObject = env->CallStaticObjectMethod(PeerRole_class, PeerRole_fromInt_method, role);
|
||||
if (env->ExceptionCheck() || peerRoleObject == NULL) {
|
||||
LOGE("Error creating PeerRole object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
peerRoleObject = env->GetStaticObjectField(PeerRole_class, field);
|
||||
|
||||
return peerRoleObject;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue