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.
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
# 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
-
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)
-
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
-
Dispatcher: Message Type Dispatcher
-
Codec: Codec based on "Packet Header + JSON" + JSON codec
-
Uses dual threads, one for output and one for input
- Zero-copy: Uses sendfile to reduce CPU copying and improve transfer efficiency
-
Each message =
[packet length][message type length][message type][JSON body] -
Message body uses nlohmann/json encoding/decoding
| Type | Technologies Used |
|-------------|------------------|
| Network Communication | Muduo |
| Data Storage | MySQL / Redis |
| JSON Parsing | nlohmann/json |
| Performance Analysis | gperftools |
| Build Tools | CMake |