From 2ec25e126f54ba1e12c5b98a7d345f18fc52e898 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Wed, 29 Jul 2020 10:33:53 +0200 Subject: clientlib: Support get_message --- ssh/client.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ssh/client.c') diff --git a/ssh/client.c b/ssh/client.c index ad0f107..a262d6f 100644 --- a/ssh/client.c +++ b/ssh/client.c @@ -285,6 +285,14 @@ static bool handle_line( ret = tomsg_history(client, args[0], count, msgid); } + } else if (sv_equals(command, "get") || + sv_equals(command, "get_message")) { + int64_t msgid; + if (parse_args(line, args, num_args = 1, false) && + parse_i64(args[0], &msgid)) { + ret = tomsg_get_message(client, msgid); + } + } else if (sv_equals(command, "on") || sv_equals(command, "is_online")) { if (parse_args(line, args, num_args = 1, false)) { @@ -326,6 +334,7 @@ static bool handle_line( " ping\n" " hist/history \n" " histb/history_before \n" + " get/get_message \n" " on/is_online \n" " act/user_active \n" " help\n" @@ -361,6 +370,7 @@ static const char* event_type_descr(enum tomsg_event_type type) { case TOMSG_EV_INVITE: return "invite"; case TOMSG_EV_SEND: return "send"; case TOMSG_EV_HISTORY: return "history"; + case TOMSG_EV_GET_MESSAGE: return "get_message"; case TOMSG_EV_PING: return "ping"; case TOMSG_EV_IS_ONLINE: return "is_online"; case TOMSG_EV_USER_ACTIVE: return "user_active"; @@ -451,6 +461,12 @@ static void handle_event(struct state *state, const struct tomsg_event event) { } break; + case TOMSG_EV_GET_MESSAGE: + printf(" %" PRIi64 " is in room %s:\n ", + event.get_message.message.msgid, event.get_message.room_name); + print_history_message(event.get_message.message); + break; + case TOMSG_EV_PING: printf(" Pong\n"); break; -- cgit v1.2.3-54-g00ecf