WebSocket protocol parser.
More...
|
enum | vtm_ws_parser_stage {
VTM_WS_PARSE_MSG_BEGIN,
VTM_WS_PARSE_FRAME_BEGIN,
VTM_WS_PARSE_FRAME_FIN_OPCODE,
VTM_WS_PARSE_FRAME_MASK_LEN7,
VTM_WS_PARSE_FRAME_LEN16,
VTM_WS_PARSE_FRAME_LEN64,
VTM_WS_PARSE_FRAME_MASK32,
VTM_WS_PARSE_FRAME_PAYLOAD,
VTM_WS_PARSE_FRAME_FINISH_CTRL,
VTM_WS_PARSE_FRAME_FINISH_DATA,
VTM_WS_PARSE_FRAME_COMPLETE,
VTM_WS_PARSE_MSG_COMPLETE,
VTM_WS_PARSE_ERROR
} |
|
VTM_API int vtm_ws_parser_init |
( |
struct vtm_ws_parser * |
par, |
|
|
enum vtm_ws_mode |
mode |
|
) |
| |
Initializes a new parser for given mode.
- Parameters
-
par | the parser that should be initialized |
mode | the mode under which the parser should run |
- Returns
- VTM_OK if the parser was successfully initialized
-
VTM_ERROR if the parser could not be initialized
Releases the parser and all allocated resources.
After this call the parser structure is no longer valid.
- Parameters
-
par | the parser that should be released |
Resets the parser to a clean state.
- Parameters
-
par | the parser that should be reset |
Lets the parser examine the input data.
- Parameters
-
par | the parser the should run |
buf | the input buffer for the parser |
- Returns
- VTM_NET_RECV_STAT_COMPLETE if a message was successfully parsed
-
VTM_NET_RECV_STAT_AGAIN if the parser need a another run with more input data
-
VTM_NET_RECV_STAT_INVALID if the input data is not a valid WebSocket message
-
VTM_NET_RECV_STAT_ERROR if an error occured for example a necessary buffer could not be allocated
Retrieves the last parsed message
- Parameters
-
| par | the parser |
[out] | msg | the message is stored here |
- Returns
- VTM_OK if the parsed message was successfully retrieved
-
VTM_ERROR if an error occured, for example a necessary buffer could not be allocated