24 #include "helloworld.grpc.pb.h"
50 const int host_port_buf_size = 1024;
51 char host_port[host_port_buf_size];
52 snprintf(host_port, host_port_buf_size,
"0.0.0.0:%d",
port);
66 jboolean is_cancelled =
env->CallBooleanMethod(
obj, is_cancelled_mid);
67 if (is_cancelled == JNI_TRUE) {
95 return reply.message();
97 return status.error_message();
102 std::unique_ptr<Greeter::Stub>
stub_;
106 extern "C" JNIEXPORT jstring JNICALL
108 JNIEnv*
env, jobject obj_unused, jstring host_raw, jint port_raw,
109 jstring message_raw) {
110 const char* host_chars =
env->GetStringUTFChars(host_raw, (jboolean*)0);
113 int port =
static_cast<int>(port_raw);
115 const char* message_chars =
env->GetStringUTFChars(message_raw, (jboolean*)0);
118 const int host_port_buf_size = 1024;
119 char host_port[host_port_buf_size];
120 snprintf(host_port, host_port_buf_size,
"%s:%d", host.c_str(),
port);
126 return env->NewStringUTF(reply.c_str());
130 extern "C" JNIEXPORT
void JNICALL
132 JNIEnv*
env, jobject obj_this, jint port_raw) {
133 int port =
static_cast<int>(port_raw);
135 jclass cls =
env->GetObjectClass(obj_this);
136 jmethodID is_cancelled_mid =
137 env->GetMethodID(cls,
"isRunServerTaskCancelled",
"()Z");