websockets
Installation
SKILL.md
WebSockets
WebSockets provide a persistent connection between a client and server that both parties can use to start sending data at any time.
When to Use
- Full-Duplex Real-Time Communication: Applications requiring continuous, low-latency, two-way message exchanges between client and server.
- Live Collaborative Canvases & Documents: Synchronizing multi-user edits, cursor coordinates, and presence indicators (Figma/Google Docs style).
- Multiplayer Online Gaming & Chat: Low-overhead messaging protocols where HTTP request-response overhead would introduce unacceptable lag.
- Financial Trading Desks: Streaming high-frequency bid/ask order book tickers with sub-millisecond updates.
Quick Start
// Server (Node.js with 'ws')
import { WebSocketServer } from "ws";
const wss = new WebSocketServer({ port: 8080 });