From 7a3654aaebf1d75303a90f3dc574881b0199779c Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期一, 01 三月 2021 14:27:04 +0800 Subject: [PATCH] 1. 更新数据查询接口 --- src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt b/src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt index 9a9b790..1950bb4 100644 --- a/src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt +++ b/src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt @@ -10,16 +10,22 @@ class ServerHandler : ChannelInboundHandlerAdapter() { + companion object { + private const val TAG = "UAV" + } + val attributeKey = AttributeKey.valueOf<String>("deviceCode") override fun channelRegistered(ctx: ChannelHandlerContext?) { super.channelRegistered(ctx) - println("------绔彛鏈塈P杩炴帴锛歔ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}") + println() + println("------${TAG}绔彛鏈塈P杩炴帴锛歔ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}") // ctx?.fireChannelActive() } override fun channelActive(ctx: ChannelHandlerContext?) { - println("------绔彛鏈塈P婵�娲伙細[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}") + println() + println("------${TAG}绔彛鏈塈P婵�娲伙細[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}") super.channelActive(ctx) } @@ -29,7 +35,8 @@ val sb = StringBuilder() if (msg is ByteArray) { - println("------鏀跺埌鐨勫師濮嬫暟鎹細[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}") + println() + println("------${TAG}鏀跺埌鐨勫師濮嬫暟鎹細[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}") msg.forEach { val a: Int = if (it < 0) { it + 256 @@ -58,7 +65,7 @@ } override fun channelInactive(ctx: ChannelHandlerContext?) { - println("------绔彛鏈塈P涓嶆椿鍔細[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}") + println("------${TAG}绔彛鏈塈P涓嶆椿鍔細[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}") super.channelInactive(ctx) } -- Gitblit v1.9.3