From 2fede14ef1191ecd8738af4be3808c087131d8a5 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Fri, 05 Jun 2026 16:03:42 +0800
Subject: [PATCH] feat(okx): 添加WebSocket订阅确认机制和优化网格交易配置

---
 src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java
index 9f9517f..8d5329b 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java
+++ b/src/main/java/com/xcong/excoin/modules/okxNewPrice/OkxGridWsClient.java
@@ -171,6 +171,7 @@
                     isConnected.set(false);
                 }
             };
+            webSocketClient.setConnectionLostTimeout(0);
             webSocketClient.connect();
         } catch (URISyntaxException e) {
             log.error("[{}] URI格式错误", logPrefix, e);
@@ -228,6 +229,21 @@
 
             if ("subscribe".equals(event) || "unsubscribe".equals(event)) {
                 log.info("[{}] {}事件: {}", logPrefix, event, response.getString("arg"));
+                // 订阅成功确认:解析频道名并通知对应 handler
+                if ("subscribe".equals(event)) {
+                    JSONObject argObj = response.getJSONObject("arg");
+                    if (argObj != null) {
+                        String channel = argObj.getString("channel");
+                        if (channel != null) {
+                            for (OkxGridChannelHandler handler : channelHandlers) {
+                                if (channel.equals(handler.getChannelName())) {
+                                    handler.onSubscribed();
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
                 return;
             }
 

--
Gitblit v1.9.1