Skip to content

Alorun/Chatroom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

106 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chatroom

Terminal Chat Room System

This project is a terminal chat room system developed based on the Muduo network library. It is implemented in C++ and emphasizes high performance and modular architecture.

Quick Start

Dependency Installation (using Arch Linux as an example)

Client Usage

sudo pacman -S cmake gperftools jemalloc jsoncpp

yay -S nlohmann-json

Server Usage

sudo pacman -S mariadb hiredis openssl gperftools jemalloc curl

yay -S redis-plus-plus nlohmann-json

Compilation

# Navigate to /new_project/muduo
mkdir build && cd build
cmake ..
make -j

Client

# Navigate to /new_project/main_client
mkdir build && cd build
cmake ..
make -j

# Run ./client

Server

# Navigate to /new_project/main_server

mkdir build && cd build

cmake ..

make -j

# Run ./server

Features

  • Account System (Registration/Login)

  • Friend Management (Add/Delete/Friend List)

  • One-on-One Chat & Group Chat

  • Offline Messages/Chat History Persistence

  • File Transfer (Upload/Download)

  • Server Integration with MySQL and Redis

  • Performance Analysis Support (gperftools)

Architecture Design

Server Modules

  • Dispatcher: Message Type Dispatcher

  • Codec: Codec based on "Packet Header + JSON"

  • Thread Pool/Connection Pool: High Concurrency Processing Capability

  • Cache Synchronization Mechanism: Periodically writes Redis cache to MySQL

Client Design

  • Dispatcher: Message Type Dispatcher

  • Codec: Codec based on "Packet Header + JSON" + JSON codec

  • Uses dual threads, one for output and one for input

File Transfer Design

  • Zero-copy: Uses sendfile to reduce CPU copying and improve transfer efficiency

Communication Protocol

  • Each message = [packet length][message type length][message type][JSON body]

  • Message body uses nlohmann/json encoding/decoding

Technology Stack

| Type | Technologies Used |

|-------------|------------------|

| Network Communication | Muduo |

| Data Storage | MySQL / Redis |

| JSON Parsing | nlohmann/json |

| Performance Analysis | gperftools |

| Build Tools | CMake |

About

Chatroom is a C++17 terminal chat system built on a Muduo-style network library, supporting private chat, group chat, file transfer, and MySQL/Redis-based message persistence.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors