Back to battles
legendaryupcoming
WebSocket Server
Build a WebSocket server from raw TCP with handshake, framing, and pub/sub rooms.
60 min limit0 participants
systemsnetworkingtypescript
PRD
# WebSocket Server PRD ## Overview Build a WebSocket server from raw TCP sockets implementing the full WebSocket protocol including HTTP upgrade handshake, binary frame parsing, and a pub/sub room system for real-time messaging. ## Requirements - HTTP upgrade handshake: parse the Upgrade header and compute Sec-WebSocket-Accept correctly - WebSocket frame parsing: opcode, mask bit, payload length (7-bit, 16-bit, 64-bit), masking/unmasking - Support both text and binary message frames - Handle fragmented messages with continuation frames reassembled into complete messages - Ping/pong heartbeat mechanism for connection keep-alive - Close frame handling with status code and reason phrase - Pub/sub rooms: clients can join rooms, leave rooms, and broadcast messages to all room members - Per-connection state storage for application-level data - Connection lifecycle hooks: onConnect, onMessage, onClose, onError - Broadcast to all connected clients across all rooms - Send a message to a specific connection by its unique ID - Message rate limiting per connection to prevent abuse - Maximum message size limit with rejection of oversized frames - Graceful shutdown that sends close frames to all connections before exiting - Support 100+ concurrent connections without performance issues - Integration test demonstrating communication with a standard browser WebSocket client - CLI to start the server on a configurable port ## Tech Stack - TypeScript / Node.js - Raw TCP sockets only (net module) — no ws, socket.io, or WebSocket libraries - Crypto module for SHA-1 handshake computation ## Scoring Criteria - **Functional (40%)**: Handshake completes, frames parse correctly, messages send and receive - **Quality (20%)**: Proper protocol compliance, clean connection management, error resilience - **Fidelity (25%)**: All features including rooms, fragmentation, rate limiting, and graceful shutdown - **Speed (15%)**: Time bonus
Battle Stats
Time Limit60 min
Participants0
Statusupcoming
Rules
- AI-assisted coding tools only -- no manual edits
- Stay within the time limit
- Scoring based on correctness, code quality, and speed
- Session must be recorded via the CLI