From 0d580a2b6e4ac2013ba5cbab046bdabf956b301b Mon Sep 17 00:00:00 2001
From: whycq <913841844@qq.com>
Date: 星期三, 14 八月 2024 15:18:17 +0800
Subject: [PATCH] #
---
app/src/main/java/com/example/agvcontroller/socket/NettyServerHandler.java | 14 ++++++++++++++
1 files changed, 14 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 73271c0..1bcb965 100644
--- a/app/src/main/java/com/example/agvcontroller/socket/NettyServerHandler.java
+++ b/app/src/main/java/com/example/agvcontroller/socket/NettyServerHandler.java
@@ -11,6 +11,7 @@
import android.util.Log;
import com.example.agvcontroller.Item;
+import com.example.agvcontroller.protocol.AgvAction;
import org.greenrobot.eventbus.EventBus;
@@ -89,6 +90,19 @@
}
}
+ public static void sendMessageToClient(String clientId, AgvAction<?> action) {
+
+
+
+ Channel channel = channelMap.get(clientId);
+ if (channel != null && channel.isActive()) {
+
+ channel.writeAndFlush(action);
+ } else {
+ Log.d(TAG, "Client " + clientId + " is not connected");
+ }
+ }
+
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
--
Gitblit v1.9.1