21 lines
742 B
TypeScript
21 lines
742 B
TypeScript
// WebSocket Keep-Alive Client with node+ws
|
|
// import { createKeepAlive } from "../src/keep.ts";
|
|
import { createKeepAlive } from "../dist/keep.js";
|
|
|
|
const WS_URL = "wss://cnb-l6o-1jg7aoevl-001.cnb.space/stable-3c0b449c6e6e37b44a8a7938c0d8a3049926a64c?reconnectionToken=a6517530-9911-406b-a65f-0d9d4b3f0d6f&reconnection=false&skipWebSocketFrames=false";
|
|
const COOKIE = "orange:workspace:cookie-session:cnb-l6o-1jg7aoevl-001=1ba3d696-1805-4c6b-b109-222738be570f";
|
|
|
|
// 使用库创建客户端
|
|
const client = createKeepAlive({
|
|
wsUrl: WS_URL,
|
|
cookie: COOKIE,
|
|
debug: true,
|
|
});
|
|
|
|
// 监听解析后的消息
|
|
client.onMessage((msg) => {
|
|
console.log(`[Received] ${msg.raw.length} bytes`);
|
|
});
|
|
|
|
console.log("开始激活 WebSocket 连接...");
|