/**
 * noVNC link backend (safe, real-time, no ban risk).
 *
 * Does not broadcast natively into Discord. Instead it shares a noVNC web URL
 * that anyone can open in a browser to watch (and optionally control) the VNC
 * desktop live. Set NOVNC_URL in .env to the browser host's LAN IP
 * (e.g. http://<browser-host-ip>:6080/vnc.html).
 *
 * Stand up noVNC once on the host with websockify, e.g.:
 *   websockify --web=/usr/share/novnc 6080 localhost:5901
 */
import type { AppConfig } from "../config.ts";
import type { ScreenStreamer, StreamContext } from "./index.ts";

export class NoVncStreamer implements ScreenStreamer {
  readonly kind = "novnc" as const;
  private active = false;
  constructor(private config: AppConfig) {}

  isActive() {
    return this.active;
  }

  async start(_ctx: StreamContext): Promise<string> {
    if (!this.config.novncUrl) {
      return "NOVNC_URL이 설정되지 않았습니다 (.env). 예: http://<브라우저호스트IP>:6080/vnc.html";
    }
    this.active = true;
    return `🖥️ VNC 화면 실시간 보기 (브라우저): ${this.config.novncUrl}`;
  }

  async stop(): Promise<void> {
    this.active = false;
  }
}
