47 lines
2.1 KiB
Java
47 lines
2.1 KiB
Java
package com.goldenchart.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;
|
|
|
|
/**
|
|
* STOMP WebSocket 브로커 설정.
|
|
*
|
|
* 클라이언트 연결 엔드포인트:
|
|
* ws(s)://host/ws/trading (SockJS fallback 지원)
|
|
*
|
|
* 구독 채널 (명세서 5.2):
|
|
* /sub/charts/{market}/{type} — 실시간 캔들 배포 (차트 렌더링 + 시그널 필드 포함, 하위 호환)
|
|
* /sub/signals/user/{userId} — [항목5] 시그널 전용 미션 크리티컬 채널 (UserId 기준)
|
|
* /sub/signals/device/{deviceId} — [항목5] 시그널 전용 채널 (DeviceId 기준, 비로그인 사용자)
|
|
* /sub/verification-issues/events — 검증 이슈 등록·단계 변경
|
|
*
|
|
* 발행 채널:
|
|
* /pub/... — 클라이언트 → 서버 (향후 확장용)
|
|
*/
|
|
@Configuration
|
|
@EnableWebSocketMessageBroker
|
|
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
|
|
|
|
@Override
|
|
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
|
// 인메모리 심플 브로커: /sub 접두사 구독 채널에 메시지 라우팅
|
|
registry.enableSimpleBroker("/sub");
|
|
// 클라이언트 발행 경로 접두사 (서버측 @MessageMapping 핸들러로 라우팅)
|
|
registry.setApplicationDestinationPrefixes("/pub");
|
|
}
|
|
|
|
@Override
|
|
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
|
// Tauri Desktop — SockJS(XHR·쿠키)는 cross-origin WebView에서 실패 → 순수 WebSocket
|
|
registry.addEndpoint("/ws/trading/ws")
|
|
.setAllowedOriginPatterns("*");
|
|
|
|
registry.addEndpoint("/ws/trading")
|
|
.setAllowedOriginPatterns("*")
|
|
.withSockJS(); // SockJS fallback (브라우저 동일 오리진)
|
|
}
|
|
}
|