alive ack implemented and stopping
This commit is contained in:
@@ -195,7 +195,7 @@ bool runRktWebview(Handle_t *handler)
|
||||
#define EVT_ALIVE_ERROR -94328
|
||||
#define WAIT_ON_EVENT_MS (10 * 1000)
|
||||
#define ALIVE_MESSAGE_INTERVAL_S 5 // Should be smaller than 10 seconds
|
||||
#define MAX_WAIT_RESULT (10 * 1000) // Maximum wait in milliseconds for a result
|
||||
#define MAX_WAIT_RESULT (2 * 1000) // Maximum wait in milliseconds for a result per time
|
||||
#define MAX_ALIVE_ACK_TIME (10 * 1000)
|
||||
|
||||
void rkt_evt_guard(void)
|
||||
@@ -275,6 +275,7 @@ void rkt_webview_cleanup()
|
||||
INFO0("Getting result of quit message\n");
|
||||
if (!handler->command_result_queue->dequeue(cmd, s, MAX_WAIT_RESULT)) {
|
||||
ERROR0("Other side has probably stopped working, no result on quit message\n");
|
||||
cmd = RESULT_QUIT;
|
||||
}
|
||||
INFO1("got %d\n", cmd);
|
||||
if (cmd == RESULT_QUIT) {
|
||||
@@ -410,7 +411,11 @@ rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js, const char
|
||||
|
||||
int result;
|
||||
std::string json_result;
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) {}
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) {
|
||||
if (handler->alive_error) {
|
||||
return result_t::failed;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -427,7 +432,11 @@ int rkt_webview_create(rkt_wv_context_t context, rktwebview_t parent)
|
||||
|
||||
int result;
|
||||
std::string json_result;
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) {}
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) {
|
||||
if (handler->alive_error) {
|
||||
return result_t::failed;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -454,7 +463,11 @@ void rkt_webview_close(rktwebview_t wv)
|
||||
handler->command_queue->enqueue(cmd, j.dump()); \
|
||||
int result; \
|
||||
std::string json_result; \
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) {} \
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) { \
|
||||
if (handler->alive_error) { \
|
||||
return result_t::failed; \
|
||||
} \
|
||||
} \
|
||||
result_t r = static_cast<result_t>(result); \
|
||||
return r;
|
||||
|
||||
@@ -498,7 +511,15 @@ rkt_data_t *rkt_webview_call_js(rktwebview_t wv, const char *js)
|
||||
|
||||
int result;
|
||||
std::string json_result;
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) {}
|
||||
while (!handler->command_result_queue->dequeue(result, json_result, MAX_WAIT_RESULT)) {
|
||||
if (handler->alive_error) {
|
||||
rkt_data_t *r = new rkt_data_t();
|
||||
r->kind = rkt_data_kind_t::js_result;
|
||||
r->data.js_result.result = result_t::eval_js_failed;
|
||||
r->data.js_result.value = strdup("");
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
rkt_data_t *r = new rkt_data_t();
|
||||
r->kind = rkt_data_kind_t::js_result;
|
||||
@@ -729,7 +750,15 @@ rkt_data_t *rkt_webview_info()
|
||||
|
||||
int open_windows_result;
|
||||
std::string none;
|
||||
while (!handler->command_result_queue->dequeue(open_windows_result, none, MAX_WAIT_RESULT)) {}
|
||||
while (!handler->command_result_queue->dequeue(open_windows_result, none, MAX_WAIT_RESULT)) {
|
||||
if (handler->alive_error) {
|
||||
d->data.metrics.open_windows = -1;
|
||||
d->data.metrics.function_calls = -1;
|
||||
d->data.metrics.log_file = strdup("");
|
||||
d->data.metrics.events = -1;
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
d->data.metrics.open_windows = open_windows_result;
|
||||
d->data.metrics.function_calls = handler->function_calls;
|
||||
|
||||
Reference in New Issue
Block a user