package com.rosetta.messenger.network

enum class ConnectionLifecycleState {
    DISCONNECTED,
    CONNECTING,
    HANDSHAKING,
    AUTHENTICATED,
    BOOTSTRAPPING,
    READY,
    DEVICE_VERIFICATION_REQUIRED
}

sealed interface ConnectionEvent {
    data class InitializeAccount(val publicKey: String, val privateKey: String) : ConnectionEvent
    data class Connect(val reason: String) : ConnectionEvent
    data class FastReconnect(val reason: String) : ConnectionEvent
    data class Disconnect(val reason: String, val clearCredentials: Boolean) : ConnectionEvent
    data class Authenticate(val publicKey: String, val privateHash: String) : ConnectionEvent
    data class ProtocolStateChanged(val state: ProtocolState) : ConnectionEvent
    data class SendPacket(val packet: Packet) : ConnectionEvent
    data class SyncCompleted(val reason: String) : ConnectionEvent
    data class OwnProfileResolved(val publicKey: String) : ConnectionEvent
    data class OwnProfileFallbackTimeout(val sessionGeneration: Long) : ConnectionEvent
}

data class ConnectionBootstrapContext(
    val accountPublicKey: String = "",
    val accountInitialized: Boolean = false,
    val protocolState: ProtocolState = ProtocolState.DISCONNECTED,
    val authenticated: Boolean = false,
    val syncCompleted: Boolean = false,
    val ownProfileResolved: Boolean = false
)
