Concepts 🚀 Project 🧮 Labs
📚 Learn / Real-time & WebSockets

⚡ Real-time & WebSockets

Pushing updates to browsers without polling — the magic behind live leaderboards.

4 concepts
1
Polling vs WebSockets
Polling: client asks 'any update?' every 5s. WebSocket: server pushes the instant it happens.
›
2
Connection manager pattern
Track active connections in a dict. broadcast() sends to all; send_json() sends to one.
›
3
Heartbeat & reconnect
Send a ping every 30s to keep the connection alive. Auto-reconnect on close.
›
4
xterm.js + PTY over WebSocket
Browser renders a terminal; PTY subprocess does the actual shell work; WebSocket pipes bytes between them.
›