sigildocs

(sigil websocket frame)

(sigil websocket frame) - WebSocket Frame Encoding/Decoding

Implements RFC 6455 WebSocket frame format. Handles frame construction, parsing, masking, and fragmentation.

Exports

Check if opcode is a control frame (close, ping, pong)

Check if opcode is a control frame (close, ping, pong)

ws-frameprocedure

Construct a ws-frame struct.

ws-frame?procedure

Test if a value is a ws-frame struct.

ws-frame-fin?procedure

Get the fin? field of a ws-frame struct.

Get the opcode field of a ws-frame struct.

Get the payload field of a ws-frame struct.

Get the payload field of a ws-frame struct.

Construct a frame-decode-result struct.

Test if a value is a frame-decode-result struct.

Get the frame field of a frame-decode-result struct.

Get the bytes-consumed field of a frame-decode-result struct.

Create a bytevector from a list of bytes

Create an empty bytevector

Generate a random 4-byte mask key Returns a bytevector of length 4

apply-maskprocedure

Apply XOR mask to data Returns new bytevector with masked data

encode-frameprocedure

Encode a WebSocket frame Client frames MUST be masked per RFC 6455

Encode a text frame (always masked for client)

Encode a binary frame (always masked for client)

Encode a close frame with optional status code

Encode a ping frame

Encode a pong frame (usually echo of ping payload)

decode-frameprocedure

Decode a WebSocket frame from bytevector Returns frame-decode-result with frame and bytes consumed Returns result with #f frame if incomplete data