org.springframework.boot
spring-boot-starter-websocket
spring-boot-starter-tomcat
org.springframework.boot
添加WebSocketConfig配置类
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springblade.constant.WebSocketConstant;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.messaging.support.MessageHeaderAccessor;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration;
import java.util.Objects;
@Slf4j
@Configuration
@EnableWebSocketMessageBroker
@ConditionalOnProperty(name = “websocket.enabled”, havingValue = “true”)
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
/**
-
方法描述: 端点配置
-
@param registry
-
@Return
-
@author caichengzhe
-
@date 2021年07月08日 10:43:55