|
@@ -1,52 +0,0 @@
|
|
|
-package com.gyee.frame.websocket;
|
|
|
-
|
|
|
-import org.springframework.context.annotation.Configuration;
|
|
|
-import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
|
|
-import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
|
|
-import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
|
|
-import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * @descrition:websocket配置类
|
|
|
- * @autho:wang
|
|
|
- * @date:2021-11-10
|
|
|
- */
|
|
|
-@Configuration
|
|
|
-@EnableWebSocketMessageBroker
|
|
|
-public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
|
|
|
-
|
|
|
- /**
|
|
|
- * 注册stomp端点,主要是起到连接作用
|
|
|
- *
|
|
|
- * @param stompEndpointRegistry
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
|
|
|
- stompEndpointRegistry
|
|
|
- .addEndpoint("/sis_service") //端点名称
|
|
|
- //.setHandshakeHandler() 握手处理,主要是连接的时候认证获取其他数据验证等
|
|
|
- //.addInterceptors() 拦截处理,和http拦截类似
|
|
|
- .setAllowedOrigins("*");//跨域
|
|
|
- // .withSockJS(); //使用sockJS1
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 注册相关服务
|
|
|
- *
|
|
|
- * @param registry
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void configureMessageBroker(MessageBrokerRegistry registry) {
|
|
|
-
|
|
|
- //topic用来广播
|
|
|
- registry.enableSimpleBroker("/topic", "/queue");
|
|
|
- //客户端名称前缀
|
|
|
- registry.setApplicationDestinationPrefixes("/app");
|
|
|
- //用户名称前
|
|
|
- registry.setUserDestinationPrefix("/user");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|