How picksan/liaotianshi works
Project type and purpose
• This is a C++-based network chat application (client/server).
• It implements user registration, login, private chat, group chat, and “remember me” via cookies or Redis.
• It is a two-tier distributed system: multiple clients connect over TCP to a single server process.
File structure
• Top-level files:
• client.h / client.cpp – encapsulates the ChatClient class and its logic
• server.h / server.cpp – encapsulates the ChatServer class and its logic
• global.h – shared definitions (constants, message formats)
• test_client.cpp – instantiates and runs ChatClient
• test_server.cpp – instantiates and runs ChatServer
• makefile – build rules
• test_redis.cpp, test_server.cpp, test_client.cpp (also for unit/feature testing)
• There is no separate “frontend” directory; both client and server are C++ console apps.
• The tutorial folder contains step-by-step markdowns showing evolution: TCP comms → multithreading → epoll + Boost thread pool → Redis integration.
README insights
• Lists external dependencies: MySQL/MariaDB (optional user data storage), Redis + hiredis (sessions).
• Mentions cookie.txt (client-side persisted login token).
• Describes compile/run workflow: “make”, “./test_server”, “./test_client”.
a. Main components
• ChatClient application (many instances)
• ChatServer application
• User database (MySQL/MariaDB) – optional for account info
• Session store (Redis) – for login state / cookies
• File‐based cookie storage (cookie.txt) on client
b. Relationships & interactions
• Clients ←→ Server over TCP sockets
• Server ←→ User DB over SQL protocol
• Server ←→ Redis via hiredis API
• Client reads/writes cookie.txt, sends token to server on connect
c. Architectural patterns & principles
• Reactor pattern on server (uses epoll)
• Thread-pool for request handling (via Boost)
• Object-oriented encapsulation: ChatClient, ChatServer classes
• Separation of concerns: networking vs. business logic vs. persistence
d. Key technologies
• C++17 (or later)
• POSIX sockets (TCP)
• epoll (Linux)
• Boost thread pool
• hiredis (Redis C client)
• MySQL/MariaDB connector (optional)
Detailed capture of essential elements
• Thread pool offshoot handling new messages
• Message flow:
1. Client sends login request → Server verifies in Redis/DB → returns cookie
2. For chat messages: Server routes to target client(s) via thread pool
3. For group chat: Server iterates member list, dispatches to each socket
• TCP port usage and config flags from global.h.