refactor: 升级 springboot 版本.

This commit is contained in:
lijiahangmax
2023-12-28 00:26:46 +08:00
parent dae142e434
commit 47657da24d
18 changed files with 218 additions and 45 deletions

View File

@@ -41,6 +41,12 @@
<artifactId>orion-ops-spring-boot-starter-web</artifactId>
</dependency>
<!-- web-socket -->
<dependency>
<groupId>com.orion.ops</groupId>
<artifactId>orion-ops-spring-boot-starter-websocket</artifactId>
</dependency>
<!-- log -->
<dependency>
<groupId>com.orion.ops</groupId>

View File

@@ -0,0 +1,63 @@
package com.orion.ops.module.asset.interceptor;
import com.orion.ops.framework.websocket.core.interceptor.UserHandshakeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.*;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import javax.annotation.Resource;
/**
* @author Jiahang Li
* @version 1.0.0
* @since 2023/12/27 23:53
*/
@Configuration
public class TerminalInterceptor implements WebSocketConfigurer {
// https://blog.csdn.net/oNew_Lifeo/article/details/130003676
// https://wstool.js.org/
@Resource
private UserHandshakeInterceptor userHandshakeInterceptor;
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new WebSocketHandler1(), "/orion/keep-alive/host/terminal")
.addInterceptors(userHandshakeInterceptor)
.setAllowedOrigins("*");
System.out.println("123");
}
static class WebSocketHandler1 implements WebSocketHandler {
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
System.out.println(1);
}
@Override
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
System.out.println(message);
}
@Override
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
System.out.println(1);
}
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
System.out.println(1);
}
@Override
public boolean supportsPartialMessages() {
return false;
}
}
}

View File

@@ -0,0 +1,37 @@
package com.orion.ops.module.asset.interceptor;
import com.orion.ops.framework.websocket.core.interceptor.UserHandshakeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.handler.TextWebSocketHandler;
import javax.annotation.Resource;
/**
* @author Jiahang Li
* @version 1.0.0
* @since 2023/12/27 23:53
*/
// @Configuration
public class TerminalInterceptor1 implements WebSocketConfigurer {
@Resource
private UserHandshakeInterceptor userHandshakeInterceptor;
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new TextWebSocketHandler() {
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
System.out.println(message);
}
}, "/orion/keep-alive/host/terminal1")
.addInterceptors(userHandshakeInterceptor)
.setAllowedOrigins("*");
System.out.println("1231");
}
}