From c74fcb7ea95c1d95cd9be679d9e10c143e7b16dc Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期一, 02 九月 2019 18:27:51 +0800 Subject: [PATCH] 添加新的三个vo类 --- src/main/kotlin/com/flightfeather/obd/socket/ServerHandler.kt | 20 +++++++++++++++----- 1 files changed, 15 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..42a6c2a 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,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() } } \ No newline at end of file -- Gitblit v1.9.3