template<bool CLIENT, bool STREAMING = true>
websocket::parser class

Template parameters
CLIENT - True or false depending on whether this parser is a client or a server. If false, this parser will expect incoming frames to be masked.
STREAMING - True or false depending on whether or not this parser expects frames be received completely. It true, partial frames will be passed to the continuation.

Contents

Public functions

auto operator!() -> bool
template<typename Function>
auto parse(uint8_t* src, uint8_t* src_end, Function&& continuation) -> uint8_t*

Function documentation

template<boolCLIENT, boolSTREAMING>
bool websocket::parser<CLIENT, STREAMING>::operator!()

Returns true if the parser encountered an error.

template<boolCLIENT, boolSTREAMING> template<typename Function>
uint8_t* websocket::parser<CLIENT, STREAMING>::parse(uint8_t* src, uint8_t* src_end, Function&& continuation)

Parse a chunk of incoming data. Calls the continuation with three arguments:

  • uint8_t opcode - the frame type, i.e. WebSocket opcode
  • uint8_t *src - the start of the payload
  • uint8_t *src_end - the end of the payload

If the return value of the continuation function is false, the parser stops parsing and goes into the error state.