(sigil websocket frame)
(sigil websocket frame) - WebSocket Frame Encoding/Decoding
Implements RFC 6455 WebSocket frame format. Handles frame construction, parsing, masking, and fragmentation.
Exports
opcode-control?procedureCheck if opcode is a control frame (close, ping, pong)
%ws-frame--typevariableCheck if opcode is a control frame (close, ping, pong)
ws-frameprocedureConstruct a ws-frame struct.
ws-frame?procedureTest if a value is a ws-frame struct.
ws-frame-fin?procedureGet the fin? field of a ws-frame struct.
ws-frame-opcodeprocedureGet the opcode field of a ws-frame struct.
ws-frame-payloadprocedureGet the payload field of a ws-frame struct.
%frame-decode-result--typevariableGet the payload field of a ws-frame struct.
frame-decode-resultprocedureConstruct a frame-decode-result struct.
frame-decode-result?procedureTest if a value is a frame-decode-result struct.
frame-decode-result-frameprocedureGet the frame field of a frame-decode-result struct.
frame-decode-result-bytes-consumedprocedureGet the bytes-consumed field of a frame-decode-result struct.
bytes->bytevectorprocedureCreate a bytevector from a list of bytes
empty-bytevectorprocedureCreate an empty bytevector
generate-mask-keyprocedureGenerate a random 4-byte mask key Returns a bytevector of length 4
apply-maskprocedureApply XOR mask to data Returns new bytevector with masked data
encode-frameprocedureEncode a WebSocket frame Client frames MUST be masked per RFC 6455
encode-text-frameprocedureEncode a text frame (always masked for client)
encode-binary-frameprocedureEncode a binary frame (always masked for client)
encode-close-frameprocedureEncode a close frame with optional status code
encode-ping-frameprocedureEncode a ping frame
encode-pong-frameprocedureEncode a pong frame (usually echo of ping payload)
decode-frameprocedureDecode a WebSocket frame from bytevector Returns frame-decode-result with frame and bytes consumed Returns result with #f frame if incomplete data