package com.jihe.punchnet.sdlan.network

enum class NakMsgCode(val code: Byte) {
    InvalidMsg(0),
    InvalidToken(1),
    NodeDisabled(2),
    NoIPAddress(3),
    NetworkFault(4),
    InternalFault(5);

    fun toByte(): Byte {
        return this.code
    }

    companion object {
        fun fromByte(code: Byte): NakMsgCode {
            return when(code) {
                1.toByte() -> InvalidToken
                2.toByte() -> NodeDisabled
                3.toByte() -> NoIPAddress
                4.toByte() -> NetworkFault
                5.toByte() -> InternalFault
                else -> InvalidMsg
            }
        }
    }
}

enum class EventType(val code: Byte) {
    KnownIP(1),
    DropIP(2),
    NatChanged(3),
    SendRegister(4),
    NetworkShutdown(0xff.toByte());

    companion object {
        fun fromByte(code: Byte): EventType {
            return when(code) {
                1.toByte() -> KnownIP
                2.toByte() -> DropIP
                3.toByte() -> NatChanged
                4.toByte() -> SendRegister
                else -> NetworkShutdown
            }
        }
    }

}