聊天室和会议初始化

This commit is contained in:
2025-12-20 18:52:33 +08:00
parent 62850717eb
commit 37224e3f95
21 changed files with 3273 additions and 22 deletions

View File

@@ -0,0 +1,37 @@
package org.xyzh.workcase.config;
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;
/**
* WebSocket配置类
* 用于聊天室实时消息推送
*/
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
// 配置消息代理
// 客户端订阅路径前缀:/topic广播、/queue点对点
config.enableSimpleBroker("/topic", "/queue");
// 客户端发送消息路径前缀
config.setApplicationDestinationPrefixes("/app");
// 点对点消息前缀
config.setUserDestinationPrefix("/user");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
// 注册STOMP端点
registry.addEndpoint("/ws/chat")
.setAllowedOriginPatterns("*") // 允许跨域
.withSockJS(); // 支持SockJS降级方案
}
}