From d539654cc3ddf34ae89351bc65452a8ca73e1109 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sun, 28 Apr 2024 12:38:34 +0200 Subject: [PATCH] handling LIST code sent back from server --- src/chat/misc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/chat/misc.c b/src/chat/misc.c index eabeddc..819eacc 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -818,6 +818,26 @@ void *why2_listen_server(void *socket) printf("%s%sEnter username (a-Z, 0-9; %d-%d characters):\n", asking_username++ > 0 ? WHY2_CLEAR_AND_GO_UP : "", WHY2_CLEAR_AND_GO_UP, min_uname, max_uname); fflush(stdout); + } else if (strncmp(message, WHY2_CHAT_CODE_LIST_SERVER, strlen(WHY2_CHAT_CODE_LIST_SERVER)) == 0) //LIST USERS + { + why2_bool printing_id = 0; + + printf("\nList:\n-----\n"); + + //ITER TROUGH LIST OF USERS FROM SERVER + for (unsigned long i = strlen(WHY2_CHAT_CODE_LIST_SERVER) + 1; i < strlen(message); i++) + { + if (message[i] == ';') + { + printf((printing_id = !printing_id) ? " (" : ")\n"); + continue; + } + + printf("%c", message[i]); + } + + printf("\n"); + fflush(stdout); } } else if (!continuing) {