WebSocketManager

WebSocketManager: auto-reconnect, dedup, ACK. Provided by src/core/websocket-manager.js.

Live Connection

Setup
This demo uses the public wss://echo.websocket.org echo server. Every JSON message you send is echoed back unchanged.

To test against your own server, change the URL in the input below. When autoConnect: false is set, the socket will not connect until you call ws.connect() explicitly.
DISCONNECTED reconnect attempts: 0

Usage

import { WebSocketManager } from '@whykusanagi/corrupted-theme/websocket-manager';

// autoConnect:false — connect only when ws.connect() is called
const ws = new WebSocketManager({
  url:            'wss://your-server.example.com/ws',
  clientId:       'overlay-client',
  autoReconnect:  true,
  maxAttempts:    10,
  trackEvents:    true,   // deduplicate by message.event_id
  enableAck:      true,   // auto-ACK messages with requires_ack
  autoConnect:    false,  // do not connect on construction
});

ws.on((msg) => {
  if (msg.type === 'connection') console.log('status:', msg.status);
  else console.log('received:', msg);
});

ws.connect();
ws.send({ type: 'hello', payload: 'world' });
ws.disconnect();
ws.destroy();  // cleanup all listeners, prevent reconnection