cwebs 0.2.1
WebSocket wire protocol
ws_iwire Struct Reference

Incremental parser for WebSocket wire protocol (in-bound). More...

#include <iwire.h>

List of all members.

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.

Detailed Description

Incremental parser for WebSocket wire protocol (in-bound).

See also:
ws_owire
ws_iwire_state
http://tools.ietf.org/html/rfc6455
Bug:
The current parser implementation cannot handle control messages injected between message fragments (see RFC6455, section 5.4).

Definition at line 74 of file iwire.h.


Member Data Documentation

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.

Parameters:
wireThe current parser state.
dataArray of bytes available to the parser state handler. Accessing past size bytes in this array results in undefined behavior.
sizeNumber 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.

See also:
baton

Definition at line 164 of file iwire.h.

External state reserved for use by application callbacks.

See also:
new_message()
end_message()
new_fragment()
end_fragment()
accept_content()

Definition at line 176 of file iwire.h.

void(* ws_iwire::end_fragment)(struct ws_iwire *wire)

Called to signal that the current fragment is complete.

Parameters:
wireThe current parser state.

This callback should be used to commit any buffered message contents.

See also:
baton

Definition at line 143 of file iwire.h.

void(* ws_iwire::end_message)(struct ws_iwire *wire)

Called to signal that all message fragments were parsed.

Parameters:
wireThe 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.

See also:
baton
ws_iwire_dead

Definition at line 104 of file iwire.h.

void(* ws_iwire::new_fragment)(struct ws_iwire *wire, uint64 size)

Called to signal that a new message fragment has arrived.

Parameters:
wireThe current parser state.
sizeThe 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().

Note:
If the message is fragmented (ws_iwire_last(wire)==0), then the total size of the message is unavailable. The WebSocket specification thus allows messages of unlimited size.
See also:
baton
ws_iwire_last
ws_iwire_mask
ws_iwire_ping
ws_iwire_pong
ws_iwire_text
ws_iwire_data
ws_iwire_dead

Definition at line 132 of file iwire.h.

void(* ws_iwire::new_message)(struct ws_iwire *wire)

Called to signal that a new message has started.

Parameters:
wireThe current parser state.
Warning:
The current parser state (other than 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.
See also:
baton

Definition at line 88 of file iwire.h.


The documentation for this struct was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines