|
|
@ -10,8 +10,11 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.web.socket.WebSocketHandler; |
|
|
|
import org.springframework.web.socket.WebSocketSession; |
|
|
|
import org.springframework.web.socket.config.annotation.EnableWebSocket; |
|
|
|
import org.springframework.web.socket.config.annotation.WebSocketConfigurer; |
|
|
|
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; |
|
|
|
import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration; |
|
|
|
import org.springframework.web.socket.server.HandshakeInterceptor; |
|
|
|
|
|
|
|
/** |
|
|
@ -23,8 +26,13 @@ import org.springframework.web.socket.server.HandshakeInterceptor; |
|
|
|
@ConditionalOnProperty(value = "websocket.enabled", havingValue = "true") |
|
|
|
@EnableConfigurationProperties(WebSocketProperties.class) |
|
|
|
@EnableWebSocket |
|
|
|
public class WebSocketConfig { |
|
|
|
|
|
|
|
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { |
|
|
|
@Override |
|
|
|
public void configureWebSocketTransport(WebSocketTransportRegistration registration) { |
|
|
|
registration.setSendTimeLimit(15 * 1000); // 消息发送最大超时
|
|
|
|
registration.setSendBufferSizeLimit(1024 * 1024); // 发送缓冲区大小
|
|
|
|
registration.setMessageSizeLimit(128 * 1024); // 消息大小限制
|
|
|
|
} |
|
|
|
@Bean |
|
|
|
public WebSocketConfigurer webSocketConfigurer(HandshakeInterceptor handshakeInterceptor, |
|
|
|
WebSocketHandler webSocketHandler, WebSocketProperties webSocketProperties) { |
|
|
|