kcg-ai-monitoring/frontend/src/services/ws.ts
htlee e6319a571c refactor: 모노레포 구조로 전환 (frontend/ + backend/ + database/)
Phase 1: 모노레포 디렉토리 구조 구축

- 기존 React 프로젝트를 frontend/ 디렉토리로 이동 (git mv)
- backend/ 디렉토리 생성 (Phase 2에서 Spring Boot 초기화)
- database/migration/ 디렉토리 생성 (Phase 2에서 Flyway 마이그레이션)
- 루트 .gitignore에 frontend/, backend/ 경로 반영
- 루트 CLAUDE.md를 모노레포 가이드로 갱신
- Makefile 추가 (dev/build/lint 통합 명령)
- frontend/vite.config.ts에 /api → :8080 백엔드 proxy 설정
- .githooks/pre-commit을 모노레포 구조에 맞게 갱신
  (frontend/ 변경 시 frontend/ 내부에서 검증)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 08:47:24 +09:00

49 lines
1.4 KiB
TypeScript

/**
* WebSocket 서비스 (샘플 구조)
*
* 향후 STOMP.js 7.3 + SockJS 1.6 설치 후 실제 연동:
* import { Client } from '@stomp/stompjs';
* import SockJS from 'sockjs-client';
*/
export interface WsConfig {
url: string;
topics: string[];
onMessage: (topic: string, body: unknown) => void;
onConnect?: () => void;
onDisconnect?: () => void;
}
/**
* WebSocket 연결 (STOMP over SockJS)
* TODO: STOMP.js + SockJS 설치 후 구현
*
* 사용 예시:
* ```
* const disconnect = connectWs({
* url: '/ws/ais',
* topics: ['/topic/vessels', '/topic/alerts'],
* onMessage: (topic, body) => {
* if (topic === '/topic/vessels') useVesselStore.getState().updatePositions(body);
* if (topic === '/topic/alerts') useEventStore.getState().addAlert(body);
* },
* });
* ```
*/
export function connectWs(_config: WsConfig): () => void {
console.warn('[WS] WebSocket not implemented — STOMP.js + SockJS 설치 필요');
// const client = new Client({
// webSocketFactory: () => new SockJS(config.url),
// onConnect: () => {
// config.topics.forEach(topic => {
// client.subscribe(topic, (msg) => config.onMessage(topic, JSON.parse(msg.body)));
// });
// config.onConnect?.();
// },
// onDisconnect: () => config.onDisconnect?.(),
// });
// client.activate();
// return () => client.deactivate();
return () => {};
}