Commit 8bf5480bbf3ab240b6e0d76750b7786f47f0bf0d

Authored by cherishsince
1 parent ab0a49a1

【增强】MidjourneyWebSocket token无效会认证失败,增加 wss 通知回调,给业务方法处理

yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/midjourney/webSocket/MidjourneyWebSocketStarter.java
@@ -56,6 +56,7 @@ public class MidjourneyWebSocketStarter implements WebSocketStarter { @@ -56,6 +56,7 @@ public class MidjourneyWebSocketStarter implements WebSocketStarter {
56 * 链接成功的 session 56 * 链接成功的 session
57 */ 57 */
58 private WebSocketSession webSocketSession = null; 58 private WebSocketSession webSocketSession = null;
  59 + private WssNotify wssNotify = null;
59 60
60 public MidjourneyWebSocketStarter(String wssServer, 61 public MidjourneyWebSocketStarter(String wssServer,
61 String resumeWss, 62 String resumeWss,
@@ -68,7 +69,8 @@ public class MidjourneyWebSocketStarter implements WebSocketStarter { @@ -68,7 +69,8 @@ public class MidjourneyWebSocketStarter implements WebSocketStarter {
68 } 69 }
69 70
70 @Override 71 @Override
71 - public void start() { 72 + public void start(WssNotify wssNotify) {
  73 + this.wssNotify = wssNotify;
72 start(false); 74 start(false);
73 } 75 }
74 76
@@ -178,6 +180,9 @@ public class MidjourneyWebSocketStarter implements WebSocketStarter { @@ -178,6 +180,9 @@ public class MidjourneyWebSocketStarter implements WebSocketStarter {
178 180
179 private void notifyWssLock(int code, String reason) { 181 private void notifyWssLock(int code, String reason) {
180 System.err.println("notifyWssLock: " + code + " - " + reason); 182 System.err.println("notifyWssLock: " + code + " - " + reason);
  183 + if (wssNotify != null) {
  184 + wssNotify.notify(code, reason);
  185 + }
181 } 186 }
182 187
183 /** 188 /**
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/midjourney/webSocket/WssNotify.java 0 → 100644
  1 +package cn.iocoder.yudao.framework.ai.midjourney.webSocket;
  2 +
  3 +/**
  4 + * 通知信息
  5 + *
  6 + * @author fansili
  7 + * @time 2024/4/29 14:21
  8 + * @since 1.0
  9 + */
  10 +public interface WssNotify {
  11 +
  12 + void notify(int code, String message);
  13 +}