How stasyao/websocket_demo works
This is a dependency-free, educational WebSocket (RFC 6455) client/server demo implemented in one Python module. Its principal workflow is to start both peers in separate processes, establish a WebSocket session over TCP with an HTTP upgrade handshake, exchange text and control frames concurrently, then complete the close handshake and TCP shutdown. The graph separates session roles from shared protocol machinery. README statements establish the end-to-end workflow; sampled source confirms selected parsing and dispatch calls, but many function bodies were not shown.
Main entry points: websocket_demo.py Server session
Components 16
Session runtime
- Process launcher
websocket_demo.py - Server session
websocket_demo.py - Client session
websocket_demo.py - Server handshake
websocket_demo.py - Client handshake
websocket_demo.py - Server ticker
websocket_demo.py - Client sender
websocket_demo.py - Connection cleanup
websocket_demo.py
Protocol engine
- HTTP helpers
websocket_demo.py - Handshake keys
websocket_demo.py - Frame codec
websocket_demo.py - Frame dispatcher
websocket_demo.py - Message assembly
websocket_demo.py - Control frames
websocket_demo.py
Observability
- Lifecycle logging
websocket_demo.py
Other components
- Demo operator
Connections 24
- Demo operator → Process launcher: runs demo
README.md - Process launcher → Server session: starts process
README.md - Process launcher → Client session: starts process
README.md - Client session → Client handshake: performs handshake
README.md - Server session → Server handshake: performs handshake
README.md - Client handshake → HTTP helpers: reads headers
README.md - Server handshake → HTTP helpers: reads headers
README.md - Client handshake → Handshake keys: generates key
README.md - Server handshake → Handshake keys: computes accept
README.md - Server session → Server ticker: sends messages
README.md - Client session → Client sender: sends messages
README.md - Server session → Frame codec: parses frames
websocket_demo.py - Client session → Frame codec: parses frames
websocket_demo.py - Server session → Frame dispatcher: dispatches frames
websocket_demo.py - Client session → Frame dispatcher: dispatches frames
websocket_demo.py - Frame dispatcher → Control frames: handles controls
websocket_demo.py - Frame dispatcher → Message assembly: assembles messages
README.md - Server ticker → Frame codec: builds frames
websocket_demo.py - Client sender → Frame codec: builds frames
README.md - Client sender → Control frames: initiates close
README.md - Server session → Connection cleanup: cleans connection
README.md - Client session → Connection cleanup: cleans connection
README.md - Server session → Lifecycle logging: logs lifecycle
README.md - Client session → Lifecycle logging: logs lifecycle
README.md