From 968498cf4ea181bff59604415fb82a6dfb8dd2bf Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 21 Feb 2024 20:18:39 +0100 Subject: [PATCH] implemented communication_time from server config --- include/chat/flags.h | 1 - src/chat/misc.c | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/chat/flags.h b/include/chat/flags.h index 65069e4..9f5f037 100644 --- a/include/chat/flags.h +++ b/include/chat/flags.h @@ -27,7 +27,6 @@ extern "C" { #define WHY2_SA struct sockaddr #define WHY2_CHAT_SERVER_PORT 1204 //PORT #define WHY2_MAX_CONNECTIONS 1000 //MAX USERS CONNECTED AT ONE TIME -#define WHY2_COMMUNICATION_TIME 300 //SECONDS WAITING BEFORE KICKING USER (TIMEOUT) #define WHY2_CLEAR_AND_GO_UP "\33[2K\r\033[A" //i mean read the name diff --git a/src/chat/misc.c b/src/chat/misc.c index 9383156..ab5bb13 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -225,7 +225,13 @@ why2_bool check_username(char *username) void *stop_oldest_thread(void *id) { - sleep(WHY2_COMMUNICATION_TIME); //yk wait + //GET THE communication_time INTEGER + char *communication_time_str = why2_chat_server_config("communication_time"); + int communication_time = atoi(communication_time_str); + why2_toml_read_free(communication_time_str); + + sleep(communication_time); //yk wait + if (waiting_list.head == NULL) return NULL; if (**(pthread_t**) waiting_list.head -> value == *(pthread_t*) id) //THREAD IS STILL ALIVE, I HOPE {