feat: 重构 WebSocket Keep-Alive 客户端,添加连接和消息处理功能,更新依赖版本,增加 keep.ts 文件
This commit is contained in:
19
test/keep.ts
Normal file
19
test/keep.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// WebSocket Keep-Alive Client with node+ws
|
||||
import { createKeepAlive } from "../src/workspace/keep-live.ts";
|
||||
|
||||
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 连接...");
|
||||
Reference in New Issue
Block a user