websocket-engineer by 404kidwiz/claude-supercode-skills
npx skills add https://github.com/404kidwiz/claude-supercode-skills --skill websocket-engineer提供实时通信专业知识,专注于 WebSocket 架构、Socket.IO 和事件驱动系统。构建低延迟、双向通信系统,可扩展至数百万并发连接。
场景: 为企业构建可扩展的聊天平台。
实现:
成果:
场景: 具有亚秒级更新的实时分析仪表板。
实现:
成果:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
场景: 低延迟多人在线游戏服务器。
实现:
成果:
What is the communication pattern?
│
├─ **Bi-directional (Chat/Game)**
│ ├─ Low Latency needed? → **WebSockets (Raw)**
│ ├─ Fallbacks/Auto-reconnect needed? → **Socket.IO**
│ └─ P2P Video/Audio? → **WebRTC**
│
├─ **One-way (Server → Client)**
│ ├─ Stock Ticker / Notifications? → **Server-Sent Events (SSE)**
│ └─ Large File Download? → **HTTP Stream**
│
└─ **High Frequency (IoT)**
└─ Constrained device? → **MQTT** (over TCP/WS)
| 规模 | 架构 | 后端 |
|---|---|---|
| < 10k 用户 | 单体架构 | 单实例 |
| 10k - 100k | 集群 | Node.js Cluster + Redis Adapter |
| 100k - 1M | 微服务 | Go/Elixir/Rust + NATS/Kafka |
| 全球 | 边缘计算 | Cloudflare Workers / PubNub / Pusher |
Upgrade: websocket, Connection: Upgrade。危险信号 → 升级给 security-engineer:
目标: 能够在多个核心/实例上扩展的聊天服务器。
步骤:
安装依赖
npm install socket.io redis @socket.io/redis-adapter
实现
const { Server } = require("socket.io");
const { createClient } = require("redis");
const { createAdapter } = require("@socket.io/redis-adapter");
const pubClient = createClient({ url: "redis://localhost:6379" });
const subClient = pubClient.duplicate();
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
const io = new Server(3000, {
adapter: createAdapter(pubClient, subClient),
cors: {
origin: "https://myapp.com",
methods: ["GET", "POST"]
}
});
io.on("connection", (socket) => {
// User joins a room (e.g., "chat-123")
socket.on("join", (room) => {
socket.join(room);
});
// Send message to room (propagates via Redis to all nodes)
socket.on("message", (data) => {
io.to(data.room).emit("chat", data.text);
});
});
});
目标: 在单台服务器上处理 5 万并发连接。
步骤:
ulimit -n 65535。/etc/security/limits.conf。sysctl -w net.ipv4.ip_local_port_range="1024 65535"。ws 代替 Socket.IO。表现:
users = [] 数组。失败原因:
正确方法:
表现:
失败原因:
正确方法:
random(0, 10s)。表现:
socket.on('message', () => { heavyCalculation(); })失败原因:
正确方法:
可扩展性:
弹性:
安全性:
每周安装
79
仓库
GitHub 星标
42
首次出现
2026 年 1 月 24 日
安全审计
安装于
opencode65
codex63
gemini-cli60
claude-code59
github-copilot53
cursor53
Provides real-time communication expertise specializing in WebSocket architecture, Socket.IO, and event-driven systems. Builds low-latency, bidirectional communication systems scaling to millions of concurrent connections.
Scenario: Building a scalable chat platform for enterprise use.
Implementation:
Results:
Scenario: Real-time analytics dashboard with sub-second updates.
Implementation:
Results:
Scenario: Low-latency multiplayer game server.
Implementation:
Results:
What is the communication pattern?
│
├─ **Bi-directional (Chat/Game)**
│ ├─ Low Latency needed? → **WebSockets (Raw)**
│ ├─ Fallbacks/Auto-reconnect needed? → **Socket.IO**
│ └─ P2P Video/Audio? → **WebRTC**
│
├─ **One-way (Server → Client)**
│ ├─ Stock Ticker / Notifications? → **Server-Sent Events (SSE)**
│ └─ Large File Download? → **HTTP Stream**
│
└─ **High Frequency (IoT)**
└─ Constrained device? → **MQTT** (over TCP/WS)
| Scale | Architecture | Backend |
|---|---|---|
| < 10k Users | Monolith Node.js | Single Instance |
| 10k - 100k | Clustering | Node.js Cluster + Redis Adapter |
| 100k - 1M | Microservices | Go/Elixir/Rust + NATS/Kafka |
| Global | Edge | Cloudflare Workers / PubNub / Pusher |
Upgrade: websocket, Connection: Upgrade.Red Flags → Escalate tosecurity-engineer:
*) with credentialsGoal: Chat server capable of scaling across multiple cores/instances.
Steps:
Install Dependencies
npm install socket.io redis @socket.io/redis-adapter
Implementation (server.js)
const { Server } = require("socket.io");
const { createClient } = require("redis");
const { createAdapter } = require("@socket.io/redis-adapter");
const pubClient = createClient({ url: "redis://localhost:6379" });
const subClient = pubClient.duplicate();
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
const io = new Server(3000, {
adapter: createAdapter(pubClient, subClient),
cors: {
origin: "https://myapp.com",
methods: ["GET", "POST"]
}
});
io.on("connection", (socket) => {
// User joins a room (e.g., "chat-123")
socket.on("join", (room) => {
socket.join(room);
});
// Send message to room (propagates via Redis to all nodes)
socket.on("message", (data) => {
io.to(data.room).emit("chat", data.text);
});
});
});
Goal: Handle 50k concurrent connections on a single server.
Steps:
File Descriptors
ulimit -n 65535./etc/security/limits.conf.Ephemeral Ports
sysctl -w net.ipv4.ip_local_port_range="1024 65535".Memory Optimization
ws (lighter) instead of Socket.IO if features not needed.What it looks like:
users = [] array in Node.js memory.Why it fails:
Correct approach:
What it looks like:
Why it fails:
Correct approach:
random(0, 10s) before reconnecting.What it looks like:
socket.on('message', () => { heavyCalculation(); })Why it fails:
Correct approach:
Scalability:
Resilience:
Security:
Weekly Installs
79
Repository
GitHub Stars
42
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode65
codex63
gemini-cli60
claude-code59
github-copilot53
cursor53
Android 整洁架构指南:模块化设计、依赖注入与数据层实现
1,400 周安装