From 9e4bd3c3363e2b767dc9efa535f447fcf0bb0ca0 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 12 八月 2024 09:48:52 +0800
Subject: [PATCH] #
---
app/src/main/java/com/example/agvcontroller/socket/NettyServerHandler.java | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/app/src/main/java/com/example/agvcontroller/socket/NettyServerHandler.java b/app/src/main/java/com/example/agvcontroller/socket/NettyServerHandler.java
index 13abdea..35c77b2 100644
--- a/app/src/main/java/com/example/agvcontroller/socket/NettyServerHandler.java
+++ b/app/src/main/java/com/example/agvcontroller/socket/NettyServerHandler.java
@@ -8,6 +8,14 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import android.util.Log;
+
+import com.example.agvcontroller.Item;
+
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
import java.util.concurrent.ConcurrentHashMap;
public class NettyServerHandler extends ChannelInboundHandlerAdapter {
@@ -19,6 +27,7 @@
public void channelActive(ChannelHandlerContext ctx) throws Exception {
String clientId = ctx.channel().remoteAddress().toString();
channelMap.put(clientId, ctx.channel());
+ EventBus.getDefault().post(new Item("1",clientId,"3"));
Log.d(TAG, "Client connected: " + clientId);
}
@@ -26,6 +35,7 @@
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
String clientId = ctx.channel().remoteAddress().toString();
channelMap.remove(clientId);
+ EventBus.getDefault().post(clientId);
Log.d(TAG, "Client disconnected: " + clientId);
}
--
Gitblit v1.9.1