Key Processes

Overview

This section introduces the three foundational processes that define how the client connects to a chat server: discovery, authentication, and connection establishment.

These steps are performed in sequence and drive the application lifecycle, resulting in one or more independent chat windows — each powered by its own ClientManager instance.

Lifecycle Summary

  • The main window creates and holds a DiscoveryManager and shows a discovery page
  • When a server is selected, a stack view pushes an embedded authentication browser and AuthManager
  • Upon successful login, an access token is emitted and passed into a newly created chat window
  • Each chat window owns its own ClientManager, which manages connection state and exposes models

Note: Discovery and authentication always occur in the main window. Chat windows are only created after a valid access token is received.

Process Breakdown

Discovery

Discovery begins the client session. When the user enters a server URL, the DiscoveryManager retrieves server metadata such as WebSocket and OAuth endpoints. This data is required to initialize both the authentication flow and the later WebSocket connection.

Authentication

Authentication uses OAuth2 via an embedded browser. Once the discovery metadata is loaded, an AuthManager is created and presented alongside the browser. When authentication completes, an access token is emitted and handed off to the connection layer.

Connection

After authentication, a new chat window is created. It owns a ClientManager instance which establishes a WebSocket connection using the discovered endpoints and received token. This manager handles real-time messaging and exposes filtered models for QML binding.

Message Routing

After connection, the WebsocketManager relays incoming server messages to the MessageBroker, which parses them into structured payloads and updates internal message models.

ClientManager exposes filtered proxy models for each channel and private conversation, allowing QML views to bind to isolated message streams within a session context.