package moe.lava.neon.api.gateway

import io.ktor.websocket.CloseReason

sealed interface GatewayCloseReason {
    sealed interface ClientInitiated : GatewayCloseReason
    sealed class ShouldReconnect(val resume: Boolean) : GatewayCloseReason
    sealed class KeepDisconnected : GatewayCloseReason

    data object MissedHeartbeat : ShouldReconnect(resume = true), ClientInitiated
    data class SkippedSequence(val next: Int) : ShouldReconnect(resume = true), ClientInitiated
    data class InvalidSession(val resumable: Boolean) : ShouldReconnect(resume = resumable), ClientInitiated
    // TODO: handle non-resumable cases properly
    data class ServerClosed(val closeCode: CloseReason) : ShouldReconnect(resume = true)
    data object ServerReconnect : ShouldReconnect(resume = true), ClientInitiated

    data object ClientPaused : KeepDisconnected(), ClientInitiated

    data object Unknown : ShouldReconnect(resume = true)
}
