diff --git a/src/chat/main/client.c b/src/chat/main/client.c index ff070cc..8e39d4b 100644 --- a/src/chat/main/client.c +++ b/src/chat/main/client.c @@ -108,15 +108,19 @@ int main(void) //TODO: Remove accents - why2_send_socket(line, NULL, listen_socket); //NULL IS SENT BECAUSE IT IS USELESS TO SEND USER FROM CLIENT - SERVER WON'T USE IT - if (strcmp(line, WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_EXIT "\n") == 0) //USER REQUESTED PROGRAM EXIT { printf("Exiting...\n"); - break; - } - free(return_line); + char *exit_cmd = why2_chat_client_get_server_exit_cmd(); + + why2_send_socket(exit_cmd, NULL, listen_socket); + why2_deallocate(exit_cmd); + } else + { + why2_send_socket(line, NULL, listen_socket); //NULL IS SENT BECAUSE IT IS USELESS TO SEND USER FROM CLIENT - SERVER WON'T USE IT + free(return_line); + } } //DEALLOCATION diff --git a/src/chat/misc.c b/src/chat/misc.c index 17596ce..6c5a9d5 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -382,6 +382,8 @@ void send_socket(char *text, char *username, int socket, why2_bool welcome) json_object_object_add(json, "min_uname", json_object_new_string(min_uname)); json_object_object_add(json, "max_tries", json_object_new_string(max_tries)); + json_object_object_add(json, "exit_cmd", json_object_new_string(WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_EXIT)); + //DEALLOCATION why2_toml_read_free(max_uname); why2_toml_read_free(min_uname); @@ -802,6 +804,7 @@ void *why2_listen_server(void *socket) max_uname = get_int_from_json_string(read, "max_uname"); min_uname = get_int_from_json_string(read, "min_uname"); max_tries = get_int_from_json_string(read, "max_tries"); + why2_chat_client_set_server_exit_cmd(get_string_from_json_string(read, "exit_cmd")); continuing = 1; }