Skip to content

feat: Implement XMPP Client Connection Manager and Refactor Build System - #20

Merged
XenoSnowFox merged 12 commits into
mainfrom
feature/client-connection-manager
Sep 4, 2026
Merged

feat: Implement XMPP Client Connection Manager and Refactor Build System#20
XenoSnowFox merged 12 commits into
mainfrom
feature/client-connection-manager

Conversation

@XenoSnowFox

Copy link
Copy Markdown
Contributor

No description provided.

Introduce a new ClientConnectionManager for XMPP client-to-server connections. It provides a module config schema for the C2S listener port (default 5222) and registers the module for config discovery, preparing the server-side connection management scaffolding.
Refactor build configuration to use a single executable target instead of multiple intermediate libraries (xtrpg_config, xtrpg_network, xtrpg_xmpp). Sources are now compiled directly into xtrpg_cpp_server.

Changes:
- Remove separate library targets and consolidate into executable
- Add ENABLE_XMPP_JID build option
- Change include/link visibility from PUBLIC to PRIVATE
- Remove commented-out legacy storage backend code
This change introduces XML stream tokenization and a dedicated XMPP client session lifecycle. TcpConnection now supports async reads without relying on shared_from_this, and the tokenizer listener contract was simplified to a raw pointer for direct callback handling. ClientConnectionManager now tracks active sessions, creates a session for each new TCP connection, and starts processing the inbound XML stream. A new ClientSession class reads socket data, passes it through the tokenizer, and handles XML events for the XMPP client flow.
Initialize Asio io_context and start a SocketConnectionListener in main. Adds includes, a global atomic shutdown flag and signal handler (SIGINT/SIGTERM/SIGHUP) to support graceful termination. Creates a ClientConnectionManager, registers it as an observer with the listener, reads the C2S port (default 5222) from config, and runs io_context on a thread pool. On shutdown the listener is stopped, io_context is stopped and all IO threads are joined. Also adds a catch-all exception handler and informational logging.
Add std::cout debug output to ClientSession's XML handler methods (openDeclaration, closeDeclaration, setAttribute, appendText) to aid troubleshooting of XML tokenization/parsing. This is a non-functional change that only emits diagnostic logs when those hooks are invoked.
Replace the old multi-observer pattern with a single raw-pointer observer API (Observable::setObserver) and simplify dispatching. Introduce XmlToken and TokenType to represent parsed XML tokens. XmlStreamTokenizer now builds and emits XmlToken instances (and text/comments) via the Observable interface instead of calling listener methods. XmlTokenListener was converted to observer interfaces for XmlToken and TokenizationError. Update ClientSession and main to use the new setObserver/onObservation API and adjust includes. This is an API-level refactor to centralize token events and streamline tokenizer → session communication.
Introduce robust lifecycle management for TCP connections and client sessions plus observer API and threading improvements. Main changes:
- Make Observable thread-safe; dispatchObservation returns bool and Observer takes context by value.
- SocketConnectionListener now accepts/io_context pointer, emits raw TcpConnection* and only keeps connections when observed.
- TcpConnection: new read(error_code, stream) callback, cancelRead(), close(callback), state-change and close callbacks, atomic state, safer async/error handling.
- ClientConnectionManager: owns listener, manages sessions with mutexes, graceful shutdown, onObservation(TcpConnection*), countConnections().
- ClientSession: owns TcpConnection*, updated start/stop/shutdown and completion notification.
- apps/main updated to construct manager with port and print connection count.
Overall: safer shutdown, clearer ownership, and synchronized callbacks.
Tidies the callback lambda in ClientConnectionManager::onObservation for readability and consistent formatting. The connection-state shutdown logic remains unchanged: sessions are still stopped when the TCP connection closes and shutdown is not in progress.
@XenoSnowFox
XenoSnowFox merged commit 1c186c9 into main Sep 4, 2026
4 checks passed
@XenoSnowFox
XenoSnowFox deleted the feature/client-connection-manager branch September 4, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant