{"id":29958493,"url":"https://github.com/kahlery/multi-user-messaging","last_synced_at":"2025-08-03T20:46:34.820Z","repository":{"id":215205857,"uuid":"730814628","full_name":"kahlery/multi-user-messaging","owner":"kahlery","description":"💬 multi-threaded console chat application implemented in C, consisting of both server and client components. The server manages user contacts and messages, while the client provides a user-friendly interface to interact with the server. The communication between the server and client is facilitated through socket programming.","archived":false,"fork":false,"pushed_at":"2024-01-02T17:00:47.000Z","size":15241,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-19T14:54:21.672Z","etag":null,"topics":["c","chat-application","console-application","multithreading","networking","readme","socket-programming"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kahlery.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-12T18:23:22.000Z","updated_at":"2024-11-03T14:30:54.000Z","dependencies_parsed_at":"2024-01-03T05:44:44.272Z","dependency_job_id":null,"html_url":"https://github.com/kahlery/multi-user-messaging","commit_stats":null,"previous_names":["kahleryasla/multi-user-messaging","kahlery/multi-user-messaging"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kahlery/multi-user-messaging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahlery%2Fmulti-user-messaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahlery%2Fmulti-user-messaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahlery%2Fmulti-user-messaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahlery%2Fmulti-user-messaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kahlery","download_url":"https://codeload.github.com/kahlery/multi-user-messaging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kahlery%2Fmulti-user-messaging/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268610652,"owners_count":24278150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","chat-application","console-application","multithreading","networking","readme","socket-programming"],"created_at":"2025-08-03T20:46:26.573Z","updated_at":"2025-08-03T20:46:34.752Z","avatar_url":"https://github.com/kahlery.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multi_User_Messaging \r\n Multithreaded Realtime Console Chat App 💬\r\n \r\n![Featured Photo](./Public/Project%20ScreenShots/12.png)\r\n\r\n# List of Contents:\r\n- [Project Description](#project-description)\r\n   - [Built With](#built-with)\r\n   - [Libraries and Dependencies](#libraries-and-dependencies)\r\n   - [Compatible With](#compatible-with)\r\n- [Usage](#usage)\r\n- [Project Structure](#project-structure)\r\n- [Future Improvements](#future-improvements)\r\n- [To be Fixed](#to-be-fixed)\r\n- [Screenshots](#screenshots)\r\n- [Code Documentation](#code-documentation)\r\n  - [server.c](#serverc)\r\n    - [Function Prototypes and Explanations](#function-prototypes-and-explanations)\r\n  - [client.c](#clientc)\r\n    - [Function Prototypes and Explanations](#function-prototypes-and-explanations-1)\r\n   - [ansiTerminalColors.h](#ansiterminalcolorsh)\r\n      - [Function Prototypes and Explanations](#function-prototypes-and-explanations-2)\r\n\r\n---\r\n# Project Description:\r\nMulti-threaded **`console`** chat application implemented in C, consisting of both server and client components. The server manages user contacts and messages, while the client provides a user-friendly interface to interact with the server. The communication between the server and client is facilitated through socket programming.\r\n\r\n#### Built With:\r\n\r\nProgramming Languages:\r\n- C\r\n\r\nFrameworks and Technologies:\r\n- No frameworks used (only standard libraries)\r\n- Only C standard libraries for Unix-like systems\r\n- Csv file system for storing messages and contacts\r\n\r\n\r\n#### Libraries and Dependencies:\r\n\r\n- Standart Libraries --\u003e Listed Only Important Ones:\r\n   - arpa/inet.h (for socket programming)\r\n   - unistd.h (for read and write functions)\r\n   - pthread.h (for multithreading)\r\n   - time.h (for date and time functions)\r\n   - sys/types.h (for socket programming)\r\n   - sys/stat.h (for file permissions)\r\n- External libraries:\r\n   - [ansiTerminalColors.h](./ansiTerminalColors.h) (written by me)\r\n- Dependencies:\r\n   - [gcc](https://gcc.gnu.org/) (GNU Compiler Collection)\r\n\r\n#### Compatible with:\r\n```diff\r\n+ Linux\r\n\r\n+ MacOS\r\n\r\n- Windows (needs to include winsock.h instead of arpa/inet.h)\r\n```\r\n\r\n---\r\n\r\n# Usage:\r\nIt is well described with screenshots in [Screenshots](#screenshots) section.\r\n\r\n---\r\n\r\n# Project Structure:\r\n\r\n```c\r\n.\r\n├── Contacts\r\n│   ├── userID.csv // example\r\n│   └── ...\r\n├── Messages\r\n│   ├── userID.csv // example\r\n│   └── ...\r\n├── Public // this folder is not included in the project\r\n│   └── Project ScreenShots\r\n│       └── ...\r\n├── Readme.md\r\n├── ansiTerminalColors.h // for colored output\r\n├── client // executable of client component\r\n├── client.c // source code of client component\r\n├── server  // executable of server component\r\n└── server.c // source code of server component\r\n\r\n5 directories, 24 files\r\n```\r\n\r\n---\r\n\r\n# Future Improvements:\r\n```diff\r\n+ Add a proper database instead of CSV files (maybe SQLite or PostgreSQL)\r\n\r\n+ Add a decent GUI (maybe with Qt)\r\n\r\n+ Listing from a specified user (in messages)\r\n```\r\n\r\n# To be Fixed:\r\n```diff\r\n- Bug: server crash when a client disconnects\r\n\r\n- Bug: deleting a message from a user deletes all messages from that user\r\n\r\n- Bug: returning to the main menu after deleting a message from a user returns to the same menu\r\n```\r\n\r\n---\r\n\r\n# Screenshots:\r\n\r\n![Screenshot 1](./Public/Project%20ScreenShots/0.png)\r\n---\r\n![Screenshot 2](./Public/Project%20ScreenShots/1.png)\r\n---\r\n![Screenshot 3](./Public/Project%20ScreenShots/2.png)\r\n---\r\n![Screenshot 4](./Public/Project%20ScreenShots/3.png)\r\n---\r\n![Screenshot 5](./Public/Project%20ScreenShots/4.png)\r\n---\r\n![Screenshot 6](./Public/Project%20ScreenShots/5.png)\r\n---\r\n![Screenshot 7](./Public/Project%20ScreenShots/6.png)\r\n---\r\n![Screenshot 8](./Public/Project%20ScreenShots/7.png)\r\n---\r\n![Screenshot 9](./Public/Project%20ScreenShots/8.png)\r\n---\r\n![Screenshot 10](./Public/Project%20ScreenShots/9.png)\r\n---\r\n![Screenshot 11](./Public/Project%20ScreenShots/10.png)\r\n---\r\n![Screenshot 12](./Public/Project%20ScreenShots/11.png)\r\n---\r\n![Screenshot 13](./Public/Project%20ScreenShots/12.png)\r\n---\r\n![Screenshot 14](./Public/Project%20ScreenShots/13.png)\r\n---\r\n\r\n# Code Documentation\r\n\r\n## server.c\r\n\r\n#### Function Prototypes and Explanations:\r\n\r\n\u003cdetails\u003e\r\n\r\n1. Handler function for each client thread\r\n\r\n   ```c \r\n   void *handleClient(void *arg)\r\n   ```\r\n   This function runs in a separate thread for each connected client. It handles incoming messages from the client, interprets user input, and performs corresponding actions.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | void *arg (client socket) |\r\n   | Output | None |\r\n\r\n---\r\n\r\n2. Getter function for the current date and time\r\n\r\n   ```c \r\n   Date getCurrentDateAndTime()\r\n   ```\r\n   This function retrieves the current date and time and returns it as a `Date` structure.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | None |\r\n   | Output | Date (structure) |\r\n\r\n---\r\n\r\n3. Response function for listing contacts\r\n\r\n   ```c \r\n   void listContacts(char *userID, int client_socket)\r\n   ```\r\n   This function reads the user's contacts from a CSV file and sends them to the client.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | char *userID, int client_socket |\r\n   | Output | Sends a list of contacts to the client |\r\n\r\n---\r\n\r\n4. Response function for listing messages from a user\r\n\r\n   ```c \r\n   void listMessagesFromUser(char *userID, Message message, int client_socket)\r\n   ```\r\n   This function reads messages from a CSV file, filters them based on the specified user, and sends the result to the client.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | char *userID, Message message, int client_socket |\r\n   | Output | Sends messages from a specified user to the client |\r\n\r\n---\r\n\r\n5. Response function for deleting a message\r\n\r\n   ```c \r\n   void deleteMessage(char *userID, Message message, int client_socket)\r\n   ```\r\n   This function deletes a specified message from the user's message history and sends a confirmation or error message to the client.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | char *userID, Message message, int client_socket |\r\n   | Output | Sends a confirmation or error message to the client |\r\n\r\n---\r\n\r\n6. Response function for adding a user\r\n\r\n   ```c \r\n   void addUser(char *userID, Message message, int client_socket)\r\n   ```\r\n   This function adds a user to the contact list and sends a confirmation message to the client.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | char *userID, Message message, int client_socket |\r\n   | Output | Sends a confirmation message to the client |\r\n\r\n---\r\n\r\n7. Response function for deleting a user\r\n\r\n   ```c \r\n   void deleteUser(char *userID, Message message, int client_socket)\r\n   ```\r\n   This function deletes a specified user from the contact list and sends a confirmation or error message to the client.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | char *userID, Message message, int client_socket |\r\n   | Output | Sends a confirmation or error message to the client |\r\n\r\n---\r\n\r\n8. Response function for sending a message\r\n\r\n   ```c \r\n   void sendMessage(char *userID, Message message, int client_socket)\r\n   ```\r\n   This function sends a message from the user to another user, updating the recipient's message history.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | char *userID, Message message, int client_socket |\r\n   | Output | Sends a confirmation message to the client |\r\n\r\n---\r\n\r\n9. Response function for checking messages\r\n\r\n   ```c \r\n   void checkMessages(char *userID, int client_socket)\r\n   ```\r\n   This function reads the user's messages from a CSV file and sends them to the client.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | char *userID, int client_socket |\r\n   | Output | Sends a list of messages to the client |\r\n\r\n---\r\n\r\n10. Function for sorting messages in a CSV file\r\n\r\n    ```c \r\n    void sortTheCSVFileAccordingToDate(char *messagesCSVPath)\r\n    ```\r\n    This function sorts the messages in a CSV file based on their dates.\r\n\r\n    |  |  |\r\n    | - | - |\r\n    | Input | char *messagesCSVPath |\r\n    | Output | None |\r\n\r\n---\r\n\r\n11. Function for comparing two dates\r\n\r\n    ```c \r\n    int compareDates(const Date *date1, const Date *date2)\r\n    ```\r\n    This function compares two date structures and returns the result.\r\n\r\n    |  |  |\r\n    | - | - |\r\n    | Input | const Date *date1, const Date *date2 |\r\n    | Output | Returns an integer (comparison result) |\r\n\r\n---\r\n\r\n12. Function for creating CSV files if they don't exist\r\n\r\n    ```c \r\n    void createCSVIfNotExists(char *userID)\r\n    ```\r\n    This function creates contacts and messages CSV files if they don't exist for the given user.\r\n\r\n    |  |  |\r\n    | - | - |\r\n    | Input | char *userID |\r\n    | Output | None |\r\n\r\n---\r\n\r\n\u003c/details\u003e\r\n\r\n## client.c\r\n\r\n#### Function Prototypes and Explanations:\r\n\r\n\u003cdetails\u003e\r\n\r\n1. Function for displaying the menu\r\n\r\n   ```c \r\n   void displayMenu()\r\n   ```\r\n   This function displays the menu options for the user.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | None |\r\n   | Output | None |\r\n\r\n---\r\n\r\n2. Request function for sending a message to the server\r\n\r\n   ```c \r\n   void sendMessageToServer(int client_socket, char *userID)\r\n   ```\r\n   This function takes user input for sending a message, constructs a `Message` structure, and sends it to the server.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | int client_socket, char *userID |\r\n   | Output | Sends a message to the server |\r\n\r\n---\r\n\r\n3. Request function for receiving messages from the server\r\n\r\n   ```c \r\n   void receiveMessagesFromServer(int client_socket, char *userID)\r\n   ```\r\n   This function receives and displays messages from the server.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | int client_socket, char *userID |\r\n   | Output | Displays messages received from the server |\r\n\r\n---\r\n\r\n4. Request function for adding a user to the contacts list\r\n\r\n   ```c \r\n   void addUserToContacts(int client_socket, char *userID)\r\n   ```\r\n   This function takes user input for adding a contact, constructs a `Message` structure, and sends it to the server.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | int client_socket, char *userID |\r\n   | Output | Adds a user to the contacts list |\r\n\r\n---\r\n\r\n5. Request function for deleting a user from the contacts list\r\n\r\n   ```c \r\n   void deleteUserFromContacts(int client_socket, char *userID)\r\n   ```\r\n   This function takes user input for deleting a contact, constructs a `Message` structure, and sends it to the server.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | int client_socket, char *userID |\r\n   | Output | Deletes a user from the contacts list |\r\n\r\n---\r\n\r\n6. Request function for displaying the list of contacts\r\n\r\n   ```c \r\n   void displayContacts(int client_socket, char *userID)\r\n   ```\r\n   This function requests and displays the list of contacts from the server.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | int client_socket, char *userID |\r\n   | Output | Displays the list of contacts |\r\n\r\n---\r\n\r\n7. Request function for displaying messages from a specified user\r\n\r\n   ```c \r\n   void displayMessagesFromUser(int client_socket, char *userID)\r\n   ```\r\n   This function takes user input for a specified user, constructs a `Message` structure, sends it to the server, and displays the response.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | int client_socket, char *userID |\r\n   | Output | Displays messages from a specified user |\r\n\r\n---\r\n\r\n8. Request function for deleting a message from a specified user\r\n\r\n   ```c \r\n   void deleteMessageFromUser(int client_socket, char *userID)\r\n   ```\r\n   This function takes user input for a specified user and message, constructs a `Message` structure, sends it to the server, and displays the response.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | int client_socket, char *userID |\r\n   | Output | Deletes a message from a specified user |\r\n\r\n---\r\n\r\n9. Function for clearing the console screen\r\n\r\n   ```c \r\n   void clearScreen()\r\n   ```\r\n   This function clears the console screen.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | None |\r\n   | Output | None |\r\n\r\n---\r\n\u003c/details\u003e\r\n\r\n## ansiTerminalColors.h\r\n\r\n#### Function Prototypes and Explanations:\r\n\r\n\u003cdetails\u003e\r\n\r\n0. Macro function for printing colored text to the console\r\n\r\n   ```c \r\n   // XXX is the color name\r\n   #define LogXXX(x) printf(ANSI_COLOR_XXX x ANSI_COLOR_RESET)\r\n   ```\r\n   This function prints colored text to the console.\r\n\r\n   |  |  |\r\n   | - | - |\r\n   | Input | char *text, char *color |\r\n   | Output | None |\r\n\r\n---\r\n\u003c/details\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkahlery%2Fmulti-user-messaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkahlery%2Fmulti-user-messaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkahlery%2Fmulti-user-messaging/lists"}