MessengerProtocol

Unified contract for multi-protocol messaging in one inbox. Protocol adapters map Smack / Trixnity / TDLib (and future SDKs) onto this surface.

Inheritors

Properties

Link copied to clipboard

Whether this protocol supports creating a brand new account on the server (vs. login-only).

Link copied to clipboard

Feature flags describing what this adapter supports (registration, history sync, etc.).

Link copied to clipboard
abstract val connectionState: StateFlow<ConnectionState>

Live connection status, observed by the UI to render connected/connecting/error states.

Link copied to clipboard
abstract val id: ProtocolId

Stable identifier for this protocol (Matrix, XMPP, Telegram, Discord, Signal).

Functions

Link copied to clipboard
open suspend fun closeConversation(conversationId: String)

Protocol hook when the user leaves a conversation screen.

Link copied to clipboard
abstract suspend fun connect(account: AccountCredentials, proxy: ProxyConfig): ConnectionResult

Authenticates with the server using stored account credentials, routed through proxy (always a Tor SOCKS5 endpoint in this app). Returns ConnectionResult.Success, a pending AuthStep via pendingAuthStep, or a failure.

Link copied to clipboard

Submits fields requested by a pending AuthStep (e.g. 2FA code, SMS code) and resumes login.

Link copied to clipboard
open suspend fun continueRegistration(sessionId: String, fields: Map<String, String>, proxy: ProxyConfig): RegistrationResult

Resumes a registration flow that returned RegistrationResult.NeedsFields or RegistrationResult.NeedsWebView.

Link copied to clipboard
abstract suspend fun disconnect(accountId: String? = null)

Tears down the connection and releases any underlying client/socket resources.

Link copied to clipboard
open fun isAccountConnected(accountId: String): Boolean

Whether accountId specifically has a live, authenticated session right now.

Link copied to clipboard
open suspend fun loadMessageHistory(conversationId: String): HistoryLoadResult

Sync full message history when the user opens a conversation.

Link copied to clipboard
abstract fun observeConversations(): Flow<List<Conversation>>

Live list of conversations (rooms/chats/DMs) for the connected account.

Link copied to clipboard
abstract fun observeMessages(conversationId: String): Flow<List<Message>>

Live list of messages for conversationId, newest-appended.

Link copied to clipboard
open suspend fun pendingAuthStep(): AuthStep?

Returns pending auth step when connect succeeds but user input is still required.

Link copied to clipboard
open suspend fun register(request: RegistrationRequest, proxy: ProxyConfig): RegistrationResult

Starts account creation on the server. Default: unsupported.

Link copied to clipboard
abstract suspend fun sendMessage(conversationId: String, body: SanitizedText, accountId: String? = null): SendResult

Sends body to conversationId and returns the delivery outcome.

Link copied to clipboard
open suspend fun startConversation(remoteId: String, initialMessage: SanitizedText? = null, accountId: String? = null): SendResult

Starts a new conversation with remoteId, optionally sending initialMessage.