mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 02:46:29 +03:00
improve naming
This commit is contained in:
@@ -19,7 +19,7 @@ interface NativeAccount {}
|
||||
export class AccountManager extends EventEmitter {
|
||||
dcn_accounts: NativeAccount
|
||||
accountDir: string
|
||||
json_rpc_started = false
|
||||
jsonRpcStarted = false
|
||||
|
||||
constructor(cwd: string, os = 'deltachat-node') {
|
||||
super()
|
||||
@@ -122,17 +122,17 @@ export class AccountManager extends EventEmitter {
|
||||
if (!callback) {
|
||||
throw new Error('no callback set')
|
||||
}
|
||||
if (this.json_rpc_started) {
|
||||
if (this.jsonRpcStarted) {
|
||||
throw new Error('jsonrpc was started already')
|
||||
}
|
||||
|
||||
binding.dcn_accounts_start_jsonrpc(this.dcn_accounts, callback.bind(this))
|
||||
debug('Started jsonrpc handler')
|
||||
this.json_rpc_started = true
|
||||
this.jsonRpcStarted = true
|
||||
}
|
||||
|
||||
jsonRPCRequest(message: string) {
|
||||
if (!this.json_rpc_started) {
|
||||
if (!this.jsonRpcStarted) {
|
||||
throw new Error(
|
||||
'jsonrpc is not active, start it with startJSONRPCHandler first'
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ typedef struct dcn_accounts_t {
|
||||
uv_thread_t event_handler_thread;
|
||||
napi_threadsafe_function threadsafe_jsonrpc_handler;
|
||||
uv_thread_t jsonrpc_thread;
|
||||
dc_json_api_instance_t* jsonrpc_instance;
|
||||
dc_jsonrpc_instance_t* jsonrpc_instance;
|
||||
int gc;
|
||||
} dcn_accounts_t;
|
||||
|
||||
@@ -2928,7 +2928,7 @@ NAPI_METHOD(dcn_accounts_unref) {
|
||||
dcn_accounts->event_handler_thread = 0;
|
||||
}
|
||||
if (dcn_accounts->jsonrpc_instance) {
|
||||
dc_json_request(dcn_accounts->jsonrpc_instance, "{}");
|
||||
dc_jsonrpc_request(dcn_accounts->jsonrpc_instance, "{}");
|
||||
uv_thread_join(&dcn_accounts->jsonrpc_thread);
|
||||
dcn_accounts->jsonrpc_instance = NULL;
|
||||
}
|
||||
@@ -3248,7 +3248,7 @@ static void accounts_jsonrpc_thread_func(void* arg)
|
||||
TRACE("accounts_jsonrpc_thread_func starting");
|
||||
char* response;
|
||||
while (true) {
|
||||
response = dc_get_next_json_response(dcn_accounts->jsonrpc_instance);
|
||||
response = dc_jsonrpc_next_response(dcn_accounts->jsonrpc_instance);
|
||||
if (response == NULL) {
|
||||
// done or broken
|
||||
break;
|
||||
@@ -3271,7 +3271,7 @@ static void accounts_jsonrpc_thread_func(void* arg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
dc_json_api_unref(dcn_accounts->jsonrpc_instance);
|
||||
dc_jsonrpc_unref(dcn_accounts->jsonrpc_instance);
|
||||
dcn_accounts->jsonrpc_instance = NULL;
|
||||
TRACE("accounts_jsonrpc_thread_func ended");
|
||||
napi_release_threadsafe_function(dcn_accounts->threadsafe_jsonrpc_handler, napi_tsfn_release);
|
||||
@@ -3339,7 +3339,7 @@ NAPI_METHOD(dcn_accounts_start_jsonrpc) {
|
||||
TRACE("done");
|
||||
|
||||
dcn_accounts->gc = 0;
|
||||
dcn_accounts->jsonrpc_instance = dc_get_json_api(dcn_accounts->dc_accounts);
|
||||
dcn_accounts->jsonrpc_instance = dc_jsonrpc_init(dcn_accounts->dc_accounts);
|
||||
|
||||
TRACE("creating uv thread..");
|
||||
uv_thread_create(&dcn_accounts->jsonrpc_thread, accounts_jsonrpc_thread_func, dcn_accounts);
|
||||
@@ -3355,7 +3355,7 @@ NAPI_METHOD(dcn_json_rpc_request) {
|
||||
NAPI_STATUS_THROWS(napi_throw_type_error(env, NULL, msg));
|
||||
}
|
||||
NAPI_ARGV_UTF8_MALLOC(request, 1);
|
||||
dc_json_request(dcn_accounts->jsonrpc_instance, request);
|
||||
dc_jsonrpc_request(dcn_accounts->jsonrpc_instance, request);
|
||||
free(request);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user