Discovery Flow

Overview

The discovery flow is the entry point for initializing a connection to a chat server. It begins when the user enters a server URL and ends with a parsed DiscoveryPayload containing endpoint metadata required for login and messaging.

This process is handled by the DiscoveryManager, which delegates the actual HTTP request and JSON parsing to DiscoveryCore. The result is then emitted to QML or application logic via success or failure signals.

This flow ensures that the application can dynamically adapt to different server configurations without requiring hardcoded URLs.

Flow Summary

  • The user enters or selects a discovery URL
  • DiscoveryManager is called with discover(urlString)
  • DiscoveryCore performs a GET request to the URL
  • The server responds with a JSON object describing auth and chat endpoints
  • The JSON is parsed into a DiscoveryPayload
  • On success, DiscoveryManager emits discoverySuccess with the payload
  • On failure, DiscoveryManager emits discoveryFailed with an error message

Components Involved

Example JSON Payload

{
    "server_name": "My Chat Server",
    "auth_endpoint": "https://example.com/auth",
    "token_endpoint": "https://example.com/token",
    "chat_endpoint": "wss://example.com/chat"
}

See also DiscoveryManager, DiscoveryPayload, and authenticationflow.html.