From 4fcb5f2e5d49bbf712945669b1de480d46595767 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 30 Oct 2024 11:32:33 +0100 Subject: Refactor server code into functions - disconnect(): for disconnecting a client and deinitializing it - sendToOthers(): for sending a message to all other clients - initClient(): for initializing a client --- chatty.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'chatty.c') diff --git a/chatty.c b/chatty.c index bd131a5..00f3f95 100644 --- a/chatty.c +++ b/chatty.c @@ -44,10 +44,11 @@ popup(u32 fg, u32 bg, char* text) tb_print(global.width / 2 - len / 2, global.height / 2, fg, bg, text); } -// Takes as paramter `struct sockaddr_in*` and uses it to connect to the server. -// When the server sends a disconnect message this function must be called with the fds struct as -// paramter. To indicate that the server is offline the fds[FDS_SERVER] is set to -1. When online -// it is set to a non-zero value. +// Connect to *address_ptr of type `struct sockaddr_in*`. If it failed wait for TIMEOUT_RECONNECT +// seconds. +// This function is meant to be run by a thread. +// An offline server means fds[FDS_SERVER] is set to -1. When online +// it is set to with the appropriate file descriptor. // Returns NULL. void* thread_reconnect(void* address_ptr) -- cgit v1.2.3-70-g09d2