WebSocketManager: auto-reconnect, dedup, ACK.
Provided by src/core/websocket-manager.js.
autoConnect: false is set, the socket will not connect
until you call ws.connect() explicitly.
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