xC: use the relay protocol's RPC for pings

This commit is contained in:
Přemysl Eric Janouch 2022-09-08 01:48:15 +02:00
parent 4ba28c6ed3
commit 3a165a595b
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 16 additions and 10 deletions

View File

@ -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<>;

24
xC.c
View File

@ -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: