Created
June 6, 2018 08:19
-
-
Save mustafaakin/28b2660b533f0e903c959da14bdbad26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func communicateJava(input interface{}) (interface{}, error) { | |
inBytes, err := json.Marshal(input) | |
inputStr := string(inBytes) | |
goRequest <- inputStr | |
respStr := <-javaResponse | |
var resp interface{} | |
err = json.Unmarshal([]byte(respStr), &resp) | |
} | |
//export Java_Test_start | |
func Java_Test_start(env *C.JNIEnv, clazz C.jclass) { | |
log.SetPrefix("GO - ") | |
go func() { | |
lambda.Start(communicateJava) | |
}() | |
} | |
//export Java_Test_writeResponse | |
func Java_Test_writeResponse(env *C.JNIEnv, clazz C.jclass, input C.jstring) { | |
a := C.convert_to_cstring(env, input) | |
b := C.GoString(a) | |
javaResponse <- b | |
} | |
//export Java_Test_readRequest | |
func Java_Test_readRequest(env *C.JNIEnv, clazz C.jclass) C.jstring { | |
input := <-goRequest | |
cstr := C.CString(input) | |
cjstring := C.convert_to_jstring(env, cstr) | |
return cjstring | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment