realtime-comm
Installation
SKILL.md
realtime-comm Skill
Goal
This skill guides the implementation of bi-directional, stateful communication.
Steps
1. Protocol Selection
| Protocol | Use Case | Pros | Cons |
|---|---|---|---|
| WebSockets | Chat, Games, Collaboration | Full Duplex, Low Latency. | Stateful (hard to scale). |
| SSE (Server-Sent Events) | Stock Tickers, Notifications | Simple (HTTP), Auto-reconnect. | One-way (Server -> Client). |
| Long Polling | Legacy Support | Works everywhere. | High server resource usage. |
2. Scaling (The Hard Part)
- Problem: Client A connects to Server 1. Client B connects to Server 2. A sends message to B. Server 1 doesn't know B.
- Solution: Redis Pub/Sub Adapter.
- Server 1 publishes event to Redis channel
room:123. - Server 2 subscribes to
room:123and forwards to Client B.
- Server 1 publishes event to Redis channel