From cf12bc45ccbb56e5026e3c2269f753b834a748ae Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 27 八月 2019 15:30:50 +0800
Subject: [PATCH] 1.完成socket的obd数据获取及数据库存储 2.完成获取obd数据的相关接口1个

---
 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