|
cwebs 0.2.1
WebSocket wire protocol
|
Incremental parser for WebSocket wire protocol (in-bound). More...
#include <iwire.h>
Public Attributes | |
| void(* | new_message )(struct ws_iwire *wire) |
| Called to signal that a new message has started. | |
| void(* | end_message )(struct ws_iwire *wire) |
| Called to signal that all message fragments were parsed. | |
| void(* | new_fragment )(struct ws_iwire *wire, uint64 size) |
| Called to signal that a new message fragment has arrived. | |
| void(* | end_fragment )(struct ws_iwire *wire) |
| Called to signal that the current fragment is complete. | |
| void(* | accept_content )(struct ws_iwire *wire, const void *data, uint64 size) |
| Called to signal that some of the message payload is available. | |
| void * | baton |
| External state reserved for use by application callbacks. | |
Incremental parser for WebSocket wire protocol (in-bound).
| void(* ws_iwire::accept_content)(struct ws_iwire *wire, const void *data, uint64 size) |
Called to signal that some of the message payload is available.
| wire | The current parser state. |
| data | Array of bytes available to the parser state handler. Accessing past size bytes in this array results in undefined behavior. |
| size | Number of bytes in data the application can process. |
The application should not assume that the entire fragment payload is received at once. The parser forwards all data as it becomes available and may break up message fragments to avoid buffering data internally. If the application wishes to buffer incoming fragments to process entire fragments at once, it may do so by accumulating the data for successive calls until end_fragment() is called.
| void* ws_iwire::baton |
External state reserved for use by application callbacks.
| void(* ws_iwire::end_fragment)(struct ws_iwire *wire) |
| void(* ws_iwire::end_message)(struct ws_iwire *wire) |
Called to signal that all message fragments were parsed.
| wire | The current parser state. |
This callback should be used to commit any buffered message contents and reset any external state before processing the next message.
If the message was a closing control frame, the application should stop processing input data and possibly shutdown input on the TCP connection.
| void(* ws_iwire::new_fragment)(struct ws_iwire *wire, uint64 size) |
Called to signal that a new message fragment has arrived.
| wire | The current parser state. |
| size | The size of the message fragment (see note below). |
This callback should be used to prepare to accept the message payload. At this point, most of the frame's header has been parsed and the different state checks (e.g. the message type) can be performed.
This call will be followed by zero or more calls to accept_content(), which will then be followed by a call to end_fragment().
ws_iwire_last(wire)==0), then the total size of the message is unavailable. The WebSocket specification thus allows messages of unlimited size.| void(* ws_iwire::new_message)(struct ws_iwire *wire) |
Called to signal that a new message has started.
| wire | The current parser state. |
baton) is unreliable: this callback is invoked before the frame header is parsed. This callback should mostly be used to clear any leftover state from the previous message.