From 9c7ddb4ac71e7b4bd298e20500ef66f58db6d329 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Tue, 28 Jul 2020 20:06:57 +0200 Subject: clientlib: Update to protocol version 2 with replies --- ssh/client.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'ssh/client.c') diff --git a/ssh/client.c b/ssh/client.c index 52f26c6..ad0f107 100644 --- a/ssh/client.c +++ b/ssh/client.c @@ -199,7 +199,7 @@ static bool handle_line( if (state->focus_room != NULL) { char *message = NULL; sv_copy(line, &message); - enum tomsg_retval ret = tomsg_send(client, state->focus_room, message, NULL); + enum tomsg_retval ret = tomsg_send(client, state->focus_room, message, -1, NULL); free(message); if (ret != TOMSG_OK) return true; return false; @@ -253,7 +253,15 @@ static bool handle_line( } else if (sv_equals(command, "s") || sv_equals(command, "send")) { if (parse_args(line, args, num_args = 2, true)) { autocomplete_roomname(state, &args[0]); - ret = tomsg_send(client, args[0], args[1], NULL); + ret = tomsg_send(client, args[0], args[1], -1, NULL); + } + + } else if (sv_equals(command, "r") || sv_equals(command, "reply")) { + int64_t replyid; + if (parse_args(line, args, num_args = 3, true) && + parse_i64(args[1], &replyid)) { + autocomplete_roomname(state, &args[0]); + ret = tomsg_send(client, args[0], args[2], replyid, NULL); } } else if (sv_equals(command, "ping")) { @@ -314,6 +322,7 @@ static bool handle_line( " create_room\n" " invite \n" " s/send \n" + " r/reply \n" " ping\n" " hist/history \n" " histb/history_before \n" @@ -365,8 +374,12 @@ static const char* event_type_descr(enum tomsg_event_type type) { } static void print_history_message(const struct history_message msg) { - printf("%" PRIi64 " \x1B[90m%" PRIi64 "\x1B[0m <%s> %s\n", - msg.msgid, msg.timestamp, msg.username, msg.message); + printf("%" PRIi64 " \x1B[90m%" PRIi64 "\x1B[0m <%s> ", + msg.msgid, msg.timestamp, msg.username); + if (msg.replyid != -1) { + printf("\x1B[32m[%" PRIi64 "<-]\x1B[0m ", msg.replyid); + } + printf("%s\n", msg.message); } static void handle_event(struct state *state, const struct tomsg_event event) { -- cgit v1.2.3-54-g00ecf