TerminalChat is a multi-client, server-based chat application that allows users to communicate in chat rooms and send private direct messages (DMs). Designed for simplicity and functionality, TerminalChat leverages socket programming and multithreading to support multiple clients seamlessly.
- Chat Rooms: Public and private chat rooms.
- Direct Messaging (DMs): Send private messages to specific users.
- Real-time Messaging: Broadcast messages to all users in a chat room.
- Command Support: Helpful commands to enhance the chat experience.
- Secure Private Rooms: Password-protected rooms for private discussions.
- User Management: Dynamic handling of active users in rooms.
- CMake (version 3.10 or higher)
- GCC/Clang (with C11 support)
- A terminal emulator
- Multiple terminal windows to simulate client connections
-
Clone this repository:
git clone https://github.com/studentBorisGans/terminalChat.git cd terminalChat -
Create a build directory:
mkdir build && cd build
-
Configure the project:
cmake ..
-
Build the project:
cmake --build . -
The compiled executables will be available in the
bin/directory.
In a terminal, navigate to the bin/ directory and run:
./ServerThe server listens for incoming client connections.
In another terminal, navigate to the bin/ directory and run:
./Client <server-ip>Replace <server-ip> with the IP address or hostname of the server (e.g., 127.0.0.1 for localhost).
/help: Display a list of available commands./dm <username> <message>: Send a direct message to a specific user./users: List all active users in the current room./exit: Leave the chat room and disconnect.
- Start the server in one terminal.
- Open multiple terminals to simulate clients.
- Connect clients to the server and:
- Join a chat room.
- Broadcast messages to the room.
- Send private messages using
/dm.
terminalChat/
├── src/
│ ├── client.c # Client implementation
│ ├── server.c # Server implementation
│ ├── chat_room.c # Chat room utilities
│ ├── network_utils.c # Network utilities
├── include/
│ ├── chat_room.h # Chat room header
│ ├── common.h # Shared constants and declarations
│ ├── network_utils.h # Network-related utilities
├── CMakeLists.txt # CMake configuration
- Start the server.
- Start a client, provide your username, and join a room:
Enter your username: Alice Connected to server as Alice. Available Chat Rooms: 1. General (Public) - 0 users 2. Devs Only (Private) - 0 users Select a chat room: 1 Welcome to the chat room!
Type a message and press Enter:
> Hello, everyone!
Use the /dm command:
> /dm Bob Hi Bob! How are you?
Use the /exit command:
> /exit