73 bool fin =
true,
bool mask =
false)
74 -> std::vector<uint8_t>;
86 -> std::optional<ws_frame_header>;
99 const std::vector<uint8_t>& data)
100 -> std::vector<uint8_t>;
111 static auto apply_mask(std::vector<uint8_t>& data,
112 const std::array<uint8_t, 4>& mask) -> void;
Provides WebSocket frame encoding and decoding functionality.
static auto generate_mask() -> std::array< uint8_t, 4 >
Generates a random 4-byte masking key.
static auto encode_frame(ws_opcode opcode, std::vector< uint8_t > &&payload, bool fin=true, bool mask=false) -> std::vector< uint8_t >
Encodes data into a WebSocket frame.
static auto decode_payload(const ws_frame_header &header, const std::vector< uint8_t > &data) -> std::vector< uint8_t >
Decodes the payload from a WebSocket frame.
static auto calculate_header_size(uint64_t payload_len, bool mask) -> size_t
Calculates the size of the frame header.
static auto apply_mask(std::vector< uint8_t > &data, const std::array< uint8_t, 4 > &mask) -> void
Applies or removes XOR masking on data.
static auto decode_header(const std::vector< uint8_t > &data) -> std::optional< ws_frame_header >
Decodes a WebSocket frame header from raw data.
ws_opcode
WebSocket frame operation codes as defined in RFC 6455.
@ text
Text frame (UTF-8 encoded)
@ close
Connection close frame.
@ continuation
Continuation frame.