instantiate and make calls to rpc server

This commit is contained in:
Ari Lazier 2016-01-13 11:07:54 -08:00
parent 55bde66ef8
commit 570607fa86
3 changed files with 19 additions and 6 deletions

View File

@ -8,6 +8,7 @@
#include "com_reacttests_RealmReactAndroid.h"
#include "JSCExecutor.h"
#include "js_init.h"
#include "rpc.hpp"
#include "platform.hpp"
#include <unordered_map>
#include <android/log.h>
@ -28,10 +29,9 @@ JNIEXPORT jstring JNICALL Java_com_reacttests_RealmReactAndroid_injectRealmJsCon
// Getting the internal storage path for the application
const char* strFileDir = env->GetStringUTFChars(fileDir , NULL);
std::string absoluteAppPath(strFileDir);
realm::set_default_realm_file_directory(strFileDir);
env->ReleaseStringUTFChars(fileDir , strFileDir);
realm::set_default_realm_file_directory(absoluteAppPath);
__android_log_print(ANDROID_LOG_ERROR, "JSRealm", "Absolute path %s", realm::default_realm_file_directory().c_str());
// load the symbol
@ -57,11 +57,16 @@ JNIEXPORT jstring JNICALL Java_com_reacttests_RealmReactAndroid_injectRealmJsCon
* Class: com_reacttests_RealmReactAndroid
* Method: setupChromeDebugModeRealmJsContext
*/
static realm_js::RPCServer *s_rpc_server;
JNIEXPORT jlong JNICALL Java_com_reacttests_RealmReactAndroid_setupChromeDebugModeRealmJsContext
(JNIEnv *, jclass)
{
__android_log_print(ANDROID_LOG_ERROR, "JSRealm", "Java_com_reacttests_RealmReactAndroid_setupChromeDebugModeRealmJsContext");
return 0;
if (s_rpc_server) {
delete s_rpc_server;
}
s_rpc_server = new realm_js::RPCServer();
return (jlong)s_rpc_server;
}
/*
@ -70,9 +75,15 @@ JNIEXPORT jstring JNICALL Java_com_reacttests_RealmReactAndroid_injectRealmJsCon
*/
JNIEXPORT jstring JNICALL Java_com_reacttests_RealmReactAndroid_processChromeDebugCommand
(JNIEnv *env, jclass, jlong rpc_server_ptr, jstring chrome_cmd)
(JNIEnv *env, jclass, jlong rpc_server_ptr, jstring chrome_cmd, jstring chrome_args)
{
__android_log_print(ANDROID_LOG_ERROR, "JSRealm", "Java_com_reacttests_RealmReactAndroid_processChromeDebugCommand");
const char* cmd = env->GetStringUTFChars(chrome_cmd, NULL);
const char* args = env->GetStringUTFChars(chrome_args, NULL);
realm_js::json json = realm_js::json::parse(args);
s_rpc_server->perform_request(cmd, json);
env->ReleaseStringUTFChars(chrome_cmd, cmd);
env->ReleaseStringUTFChars(chrome_args, args);
return env->NewStringUTF("Echo");
}

View File

@ -27,7 +27,7 @@ JNIEXPORT jlong JNICALL Java_com_reacttests_RealmReactAndroid_setupChromeDebugMo
* Method: processsetupChromeDebugCommand
*/
JNIEXPORT jstring JNICALL Java_com_reacttests_RealmReactAndroid_processChromeDebugCommand
(JNIEnv *, jclass, jlong, jstring);
(JNIEnv *, jclass, jlong, jstring, jstring);
#ifdef __cplusplus

View File

@ -3,4 +3,6 @@ cp ../../react-native/android/app/build/outputs/aar/app-debug.aar android/app/li
rm -rf node_modules/realm node_modules/realm-tests
npm install realm realm-tests
cp ../../src/object-store/parser/queryTests.json node_modules/realm-tests/
adb forward tcp:8082 tcp:8082
adb reverse tcp:8081 tcp:8081
react-native run-android