/**
 * 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 () => {};
}
