How singhdevhub-lovepreet/chatroomcpp works
Main Components
• Server Component:
– Responsible for accepting client connections.
– Uses Boost.Asio’s io_context and an acceptor for managing incoming sockets.
– Creates and maintains a “Room” for clients.
• Room Component:
– Manages the set of active client sessions (participants).
– Broadcasts messages to every participant.
• Session Component:
– Represents an individual client connection.
– Handles asynchronous reading (async_read) and writing (async_write) to the client socket.
– Inherits (or implements) an abstract Participant interface.
• Message Component:
– Encapsulates the logic for message encoding/decoding.
– Manages the message header, body, and calculates message length.
• Client Component:
– Runs with its own io_context and an additional dedicated thread to handle user input.
– Communicates with the server using asynchronous operations.
• Boost.Asio and Threading:
– Illustrate the role of Boost.Asio’s asynchronous I/O and thread models that support concurrency.
– Represent the separation of the IO thread (running io_context.run()) and the input thread on the client.
Relationships and Interactions
• That each Session holds a reference to the Room, indicating the dependency for message distribution.
• Session to Message with a relationship that indicates each session has its own queue of messages that it is responsible for sending.
Architectural Patterns and Design Principles
• Asynchronous I/O Pattern:
– Clearly annotate async_read and async_write operations.
– Mark the use of Boost.Asio’s completion handlers and post() for safe thread operations.
• Multi-threading:
– Emphasize the separation of the IO thread and input handling (especially in the client).
• Modularity:
– Show how the Session, Room, and Message components are individually responsible for their functionality.
Relevant Technologies and Frameworks
• Mention C++ as the implementation language and note any reliance on threading libraries from the standard library.
• (Optionally) Note that the project uses Makefile for building and GitHub Actions for CI/CD via the .github/workflows directory.