Skip to content

GirishSCodes/ChatRoom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I'll create a README for your Chat Room project. Let me first check the CMakeLists.txt to understand the build configuration better.

ChatRoom Project

A C++ chat room application built with Boost.Asio library, demonstrating CMake usage, multi-file linking, and Boost library integration.

Project Purpose

This project was created to learn and practice:

  • CMake build system configuration
  • Linking multiple C++ source files
  • Boost library setup and linking
  • Asynchronous network programming with Boost.Asio

Overview

The ChatRoom application implements a client-server architecture where multiple clients can connect to a central chat server and exchange messages in real-time. The server handles multiple concurrent connections using asynchronous I/O operations.

Technical Stack

  • Language: C++17
  • Networking Library: Boost.Asio 1.90.0
  • Build System: CMake 3.16+
  • Platform: Windows (with Winsock2 support)

Project Structure

ChatRoom/
├── CMakeLists.txt          # CMake build configuration
├── chatRoom.hpp            # Chat room server header
├── chatRoom.cpp            # Chat room server implementation
├── client.cpp              # Client application
├── message.hpp             # Message handling utilities
└── .gitignore              # Git ignore file

Prerequisites

  1. C++ Compiler with C++17 support
  2. Boost.Asio Library (version 1.90.0 or similar)
  3. CMake (version 3.16 or higher)
  4. Windows Platform (project configured for Windows networking)

Build Instructions

  1. Install Boost.Asio:

    • Download and extract Boost (e.g., to C:/Users/hp/Downloads/boost_1_90_0/boost_1_90_0)
    • Update the BOOST_ROOT path in CMakeLists.txt if necessary
  2. Build the project:

    mkdir build
    cd build
    cmake ..
    cmake --build .
  3. Run the applications:

    # Start the server (in one terminal)
    ./server.exe <port>
    
    # Start clients (in separate terminals)
    ./client.exe <port>

Usage

  1. Start the server by running server.exe with a port number:

    server.exe 8080
    
  2. Connect clients by running client.exe with the same port:

    client.exe 8080
    
  3. Type messages in the client terminal and press Enter to send

  4. Messages will be broadcast to all connected clients

Key Components

Message System (message.hpp)

  • Handles message serialization with fixed header (4 bytes) and variable body
  • Maximum message size: 512 bytes
  • Provides encoding/decoding utilities

Chat Room Server (chatRoom.hpp/cpp)

  • Participant interface for chat participants
  • Room class manages connected participants and message broadcasting
  • Session class handles individual client connections
  • Supports up to 100 concurrent participants

Client Application (client.cpp)

  • Connects to the chat server
  • Handles asynchronous message sending and receiving
  • Simple command-line interface for user interaction

CMake Configuration Details

The CMakeLists.txt demonstrates:

  • Setting C++17 standard
  • Configuring Boost library paths
  • Creating separate executables for server and client
  • Linking Windows networking libraries (ws2_32, mswsock)
  • Private include directory configuration

Network Architecture

  • Asynchronous I/O: Uses Boost.Asio for non-blocking operations
  • TCP Protocol: Reliable message delivery
  • Message Format: Header-based message framing
  • Concurrency: Multiple clients handled simultaneously

Learning Outcomes

This project successfully demonstrates:

  • CMake project configuration for multi-file C++ projects
  • External library (Boost) integration and linking
  • Header-only library usage
  • Platform-specific library linking (Windows networking)
  • Asynchronous programming patterns
  • Object-oriented design in network applications

Limitations

  • Windows-specific networking configuration
  • Basic message format without encryption
  • No user authentication
  • Simple command-line interface

Future Enhancements

  • Cross-platform compatibility (Linux/macOS)
  • User authentication system
  • Message encryption
  • File sharing capabilities
  • Private messaging between clients

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published