From 197d6766d056fda4fdf9e1f9ee26de9f9a480ef5 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期四, 05 九月 2019 10:32:58 +0800 Subject: [PATCH] 完成警报、阈值的插入、更新、获取等接口 --- src/main/kotlin/com/flightfeather/obd/socket/ServerHandler.kt | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/obd/socket/ServerHandler.kt b/src/main/kotlin/com/flightfeather/obd/socket/ServerHandler.kt index e1480ee..9dd08db 100644 --- a/src/main/kotlin/com/flightfeather/obd/socket/ServerHandler.kt +++ b/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,17 @@ override fun channelRead(ctx: ChannelHandlerContext?, msg: Any?) { super.channelRead(ctx, msg) - val attribute = ctx?.channel()?.attr(attributeKey)?.apply { - if (get() == null) { -// set() - } + println("------鏀跺埌鐨勫師濮嬫暟鎹細$msg") + 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 +44,7 @@ } override fun exceptionCaught(ctx: ChannelHandlerContext?, cause: Throwable?) { - super.exceptionCaught(ctx, cause) + cause?.printStackTrace() + ctx?.close() } } \ No newline at end of file -- Gitblit v1.9.3