initial commit

This commit is contained in:
xiaomai
2025-10-07 11:59:55 +08:00
commit 03776ee64a
9 changed files with 468 additions and 0 deletions

27
client/test-client.js Normal file
View File

@@ -0,0 +1,27 @@
import WebSocket from "ws";
const ws = new WebSocket("ws://localhost:8080");
ws.on("open", () => {
console.log("✅ 已连接 WebSocket");
ws.send(JSON.stringify({ type: "auth", app: "demo" }));
ws.send(JSON.stringify({ type: "subscribe", channel: "chat" }));
setTimeout(() => {
ws.send(
JSON.stringify({
type: "publish",
app: "demo",
channel: "chat",
event: "message",
data: { text: "Hello Redis WS 🚀" },
})
);
}, 2000);
});
ws.on("message", (msg) => {
console.log("📩 收到消息:", msg.toString());
});