Expand description
WebSocket handler implementing the tty-web binary protocol.
§Wire protocol
All WebSocket messages are binary frames. The first byte is the command, the rest is the payload.
| Direction | Cmd | Payload | Description |
|---|---|---|---|
| client → server | 0x00 | raw bytes | Terminal input |
| client → server | 0x01 | rows(u16 BE) + cols(u16 BE) | Resize |
| server → client | 0x00 | raw bytes | Terminal output |
| server → client | 0x10 | UUID string | Session ID |
| server → client | 0x12 | — | Shell exited |
| server → client | 0x13 | rows(u16 BE) + cols(u16 BE) | Window size |
| server → client | 0x14 | — | Replay end |
Enums§
Constants§
- CLOSE_
SESSION_ 🔒NOT_ FOUND - WebSocket close code: requested session not found.
- CMD_
INPUT 🔒 - Client → Server: terminal input.
- CMD_
OUTPUT 🔒 - Server → Client: terminal output.
- CMD_
REPLAY_ 🔒END - Server → Client: end of scrollback replay.
- CMD_
RESIZE 🔒 - Client → Server: resize (4-byte payload: rows u16 BE, cols u16 BE).
- CMD_
SESSION_ 🔒ID - Server → Client: session UUID string.
- CMD_
SHELL_ 🔒EXIT - Server → Client: shell process exited.
- CMD_
WINDOW_ 🔒SIZE - Server → Client: current PTY window size (4-byte payload: rows u16 BE, cols u16 BE).
Functions§
- encode_
window_ 🔒size - Encode a window size as 4 big-endian bytes (rows, cols).
- handle_
client_ 🔒message - handle_
socket 🔒 - parse_
client_ 🔒message - resolve_
session 🔒 - send_
frame 🔒 - Send a protocol frame (command byte + payload) over the WebSocket.
- ws_
handler