Ejemplo n.º 1
0
/* Retrieve the JNI environment for this thread */
static JNIEnv *get_jni_env (void) {
    JNIEnv *env = reinterpret_cast<JNIEnv*> (pthread_getspecific (current_jni_env));

    if (env == nullptr) {
        env = attach_current_thread ();
        pthread_setspecific (current_jni_env, env);
    }

    return env;
}
Ejemplo n.º 2
0
/* Retrieve the JNI environment for this thread */
static JNIEnv *get_jni_env (void) {
    JNIEnv *env;

    if ((env = pthread_getspecific (current_jni_env)) == NULL) {
        env = attach_current_thread ();
        pthread_setspecific (current_jni_env, env);
    }

    return env;
}
Ejemplo n.º 3
0
void lobi_showChatView(ANativeActivity *nativeActivity) {
    JavaVM *vm = nativeActivity->vm;
    attach_current_thread_result_t res;
    attach_current_thread(vm, &res);
    JNIEnv *env = res.env;
    jobject thiz = nativeActivity->clazz;

    jclass klass = (*env)->GetObjectClass(env, thiz);
    jmethodID methodj = (*env)->GetMethodID(env, klass, "showChatView", "()V");

    (*env)->CallVoidMethod(env, thiz, methodj);

    detach_current_thread(vm, &res);
}
Ejemplo n.º 4
0
void lobi_signupWithBaseName(ANativeActivity *nativeActivity, lobi_api_callback_t callback, void *userData) {
    JavaVM *vm = nativeActivity->vm;
    attach_current_thread_result_t res;
    attach_current_thread(vm, &res);
    JNIEnv *env = res.env;
    jobject thiz = nativeActivity->clazz;

    jclass klass = (*env)->GetObjectClass(env, thiz);
    jmethodID methodj = (*env)->GetMethodID(env, klass, "signupWithBaseName", "(JJ)V");

    (*env)->CallVoidMethod(env, thiz, methodj, (jlong)callback, (jlong)userData);

    detach_current_thread(vm, &res);
}
Ejemplo n.º 5
0
void lobi_showToast(ANativeActivity *nativeActivity, const char *message) {
    JavaVM *vm = nativeActivity->vm;
    attach_current_thread_result_t res;
    attach_current_thread(vm, &res);
    JNIEnv *env = res.env;
    jobject thiz = nativeActivity->clazz;

    jclass klass = (*env)->GetObjectClass(env, thiz);
    jstring jstrMessage = (*env)->NewStringUTF(env, message);
    jmethodID methodj = (*env)->GetMethodID(env, klass, "showToast", "(Ljava/lang/String;)V");
    (*env)->CallVoidMethod(env, thiz, methodj, jstrMessage);

    (*env)->DeleteLocalRef(env, jstrMessage);

    detach_current_thread(vm, &res);
}
Ejemplo n.º 6
0
bool lobi_isSignedIn(ANativeActivity *nativeActivity) {
    JavaVM *vm = nativeActivity->vm;
    attach_current_thread_result_t res;
    attach_current_thread(vm, &res);
    JNIEnv *env = res.env;
    jobject thiz = nativeActivity->clazz;

    jclass klass = (*env)->GetObjectClass(env, thiz);
    jmethodID methodj = (*env)->GetMethodID(env, klass, "isSignedIn", "()Z");

    bool signedIn = (bool)(*env)->CallBooleanMethod(env, thiz, methodj);

    detach_current_thread(vm, &res);
    
    return signedIn;
}
Ejemplo n.º 7
0
void lobi_joinGroupWithExternalID(ANativeActivity *nativeActivity, const char *groupExternalId, const char *groupName, lobi_api_callback_t callback, void *userData) {
    JavaVM *vm = nativeActivity->vm;
    attach_current_thread_result_t res;
    attach_current_thread(vm, &res);
    JNIEnv *env = res.env;
    jobject thiz = nativeActivity->clazz;

    jclass klass = (*env)->GetObjectClass(env, thiz);
    jmethodID methodj = (*env)->GetMethodID(env, klass, "joinGroupWithExternalID", "(Ljava/lang/String;Ljava/lang/String;JJ)V");

    jstring jstrGroupExternalId = (*env)->NewStringUTF(env, groupExternalId);
    jstring jstrGroupName = (*env)->NewStringUTF(env, groupName);

    (*env)->CallVoidMethod(env, thiz, methodj, jstrGroupExternalId, jstrGroupName, (jlong)callback, (jlong)userData);

    (*env)->DeleteLocalRef(env, jstrGroupExternalId);
    (*env)->DeleteLocalRef(env, jstrGroupName);
    
    detach_current_thread(vm, &res);
}