From 3a165a595ba75958d360a61fdb173b19f71096dd Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Thu, 8 Sep 2022 01:48:15 +0200 Subject: xC: use the relay protocol's RPC for pings --- xC-proto | 2 ++ xC.c | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/xC-proto b/xC-proto index 46955e7..c44f095 100644 --- a/xC-proto +++ b/xC-proto @@ -129,6 +129,8 @@ struct EventMessage { case RESPONSE: u32 command_seq; union ResponseData switch (Command command) { + case PING: + void; case BUFFER_COMPLETE: u32 start; string completions<>; diff --git a/xC.c b/xC.c index 1a30f85..2644bce 100644 --- a/xC.c +++ b/xC.c @@ -3189,6 +3189,16 @@ relay_prepare_error (struct app_context *ctx, uint32_t seq, const char *message) e->error = str_from_cstr (message); } +static struct relay_event_data_response * +relay_prepare_response (struct app_context *ctx, uint32_t seq) +{ + struct relay_event_message *m = relay_prepare (ctx); + struct relay_event_data_response *e = &m->data.response; + e->event = RELAY_EVENT_RESPONSE; + e->command_seq = seq; + return e; +} + // --- Terminal output --------------------------------------------------------- /// Default colour pair @@ -15267,12 +15277,8 @@ client_process_buffer_complete (struct client *c, uint32_t seq, goto out_internal; } - struct relay_event_data_response *e = - &relay_prepare (c->ctx)->data.response; - e->event = RELAY_EVENT_RESPONSE; - e->command_seq = seq; + struct relay_event_data_response *e = relay_prepare_response (c->ctx, seq); e->data.command = RELAY_COMMAND_BUFFER_COMPLETE; - struct relay_response_data_buffer_complete *resp = &e->data.buffer_complete; resp->start = start; @@ -15291,10 +15297,7 @@ static void client_process_buffer_log (struct client *c, uint32_t seq, struct buffer *buffer) { - struct relay_event_data_response *e = - &relay_prepare (c->ctx)->data.response; - e->event = RELAY_EVENT_RESPONSE; - e->command_seq = seq; + struct relay_event_data_response *e = relay_prepare_response (c->ctx, seq); e->data.command = RELAY_COMMAND_BUFFER_LOG; char *path = buffer_get_log_path (buffer); @@ -15357,7 +15360,8 @@ client_process_message (struct client *c, client_resync (c); break; case RELAY_COMMAND_PING: - relay_prepare_ping (c->ctx); + relay_prepare_response (c->ctx, m->command_seq) + ->data.command = RELAY_COMMAND_PING; relay_send (c); break; case RELAY_COMMAND_ACTIVE: -- cgit v1.2.3-70-g09d2