Module wsc_lib

Purely functional aspects of websocket client comms.

Authors: Jeremy Ong, Michael Coles.

Description

Purely functional aspects of websocket client comms.

Herein live all the functions for pure data processing.

Function Index

create_auth_header/3
create_handshake/2
decode_frame/2Start or continue continuation payload with length less than 126 bytes.
decode_frame/5Length known and still missing data.
encode_frame/1Encodes the data with a header (including a masking key) and masks the data.
generate_ws_key/0Key sent in initial handshake.
mask_payload/2The payload is masked using a masking key byte by byte.
validate_handshake/2Validate handshake response challenge.

Function Details

create_auth_header/3

create_auth_header(Type::basic, User::binary(), Pass::binary()) -> {binary(), binary()}

create_handshake/2

create_handshake(WSReq::websocket_req:req(), ExtraHeaders::[{string(), string()}]) -> iolist()

decode_frame/2

decode_frame(WSReq, Frame) -> any()

Start or continue continuation payload with length less than 126 bytes

decode_frame/5

decode_frame(WSReq::websocket_req:req(), Opcode::websocket_req:opcode(), Len::non_neg_integer(), Data::binary(), Buffer::binary()) -> {recv, websocket_req:req(), IncompleteFrame::binary()} | {frame, {OpcodeName::atom(), Payload::binary()}, websocket_req:req(), Rest::binary()} | {close, Reason::term(), websocket_req:req()}

Length known and still missing data

encode_frame/1

encode_frame(Type::websocket_req:frame()) -> binary()

Encodes the data with a header (including a masking key) and masks the data

generate_ws_key/0

generate_ws_key() -> binary()

Key sent in initial handshake

mask_payload/2

mask_payload(MaskingKey, Payload) -> any()

The payload is masked using a masking key byte by byte. Can do it in 4 byte chunks to save time until there is left than 4 bytes left

validate_handshake/2

validate_handshake(HandshakeResponse::binary(), Key::binary()) -> {ok, binary()} | {notfound, binary()} | {error, term()}

Validate handshake response challenge


Generated by EDoc