src/main/kotlin/com/flightfeather/obd/socket/ServerHandler.kt
@@ -1,8 +1,12 @@
package com.flightfeather.obd.socket
import com.flightfeather.obd.domain.entity.ObdData
import com.google.gson.Gson
import io.netty.channel.ChannelHandler
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.ChannelInboundHandlerAdapter
import io.netty.util.AttributeKey
class ServerHandler : ChannelInboundHandlerAdapter() {
@@ -18,11 +22,16 @@
    override fun channelRead(ctx: ChannelHandlerContext?, msg: Any?) {
        super.channelRead(ctx, msg)
        val attribute = ctx?.channel()?.attr(attributeKey)?.apply {
            if (get() == null) {
//                set()
            }
        if (msg is String) {
            MessageManager().dealMsg(msg, ctx)
        }
//        val attribute = ctx?.channel()?.attr(attributeKey)?.apply {
//            if (get() == null) {
//                set(data.obdVin)
//            }
//        }
    }
    override fun channelReadComplete(ctx: ChannelHandlerContext?) {
@@ -34,6 +43,7 @@
    }
    override fun exceptionCaught(ctx: ChannelHandlerContext?, cause: Throwable?) {
        super.exceptionCaught(ctx, cause)
        cause?.printStackTrace()
        ctx?.close()
    }
}