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

This commit is contained in:
cherishsince 2024-04-29 14:51:05 +08:00
parent ab0a49a1a7
commit 8bf5480bbf
2 changed files with 19 additions and 1 deletions

View File

@ -56,6 +56,7 @@ public class MidjourneyWebSocketStarter implements WebSocketStarter {
* 链接成功的 session * 链接成功的 session
*/ */
private WebSocketSession webSocketSession = null; private WebSocketSession webSocketSession = null;
private WssNotify wssNotify = null;
public MidjourneyWebSocketStarter(String wssServer, public MidjourneyWebSocketStarter(String wssServer,
String resumeWss, String resumeWss,
@ -68,7 +69,8 @@ public class MidjourneyWebSocketStarter implements WebSocketStarter {
} }
@Override @Override
public void start() { public void start(WssNotify wssNotify) {
this.wssNotify = wssNotify;
start(false); start(false);
} }
@ -178,6 +180,9 @@ public class MidjourneyWebSocketStarter implements WebSocketStarter {
private void notifyWssLock(int code, String reason) { private void notifyWssLock(int code, String reason) {
System.err.println("notifyWssLock: " + code + " - " + reason); System.err.println("notifyWssLock: " + code + " - " + reason);
if (wssNotify != null) {
wssNotify.notify(code, reason);
}
} }
/** /**

View File

@ -0,0 +1,13 @@
package cn.iocoder.yudao.framework.ai.midjourney.webSocket;
/**
* 通知信息
*
* @author fansili
* @time 2024/4/29 14:21
* @since 1.0
*/
public interface WssNotify {
void notify(int code, String message);
}