package com.flightfeather.obd.socket
|
|
import io.netty.channel.ChannelHandlerContext
|
import io.netty.channel.ChannelInboundHandlerAdapter
|
import io.netty.util.AttributeKey
|
|
class ServerHandler : ChannelInboundHandlerAdapter() {
|
|
val attributeKey = AttributeKey.valueOf<String>("deviceCode")
|
|
override fun channelRegistered(ctx: ChannelHandlerContext?) {
|
super.channelRegistered(ctx)
|
}
|
|
override fun channelActive(ctx: ChannelHandlerContext?) {
|
super.channelActive(ctx)
|
}
|
|
override fun channelRead(ctx: ChannelHandlerContext?, msg: Any?) {
|
super.channelRead(ctx, msg)
|
val attribute = ctx?.channel()?.attr(attributeKey)?.apply {
|
if (get() == null) {
|
// set()
|
}
|
}
|
}
|
|
override fun channelReadComplete(ctx: ChannelHandlerContext?) {
|
super.channelReadComplete(ctx)
|
}
|
|
override fun channelInactive(ctx: ChannelHandlerContext?) {
|
super.channelInactive(ctx)
|
}
|
|
override fun exceptionCaught(ctx: ChannelHandlerContext?, cause: Throwable?) {
|
super.exceptionCaught(ctx, cause)
|
}
|
}
|