cwebs 0.2.1
WebSocket wire protocol
ws_owire Struct Reference

Incremental writer for WebSocket wire protocol (out-bound). More...

#include <owire.h>

List of all members.

Public Attributes

void(* accept_content )(struct ws_owire *wire, const void *data, uint64 size)
 Called to signal that some data should be transferred.
void(* rand )(struct ws_owire *wire, uint8 mask[4])
 Called to signal that a mask must be generated.
void * baton
 External state reserved for use by application callbacks.
void * prng
 External state reserved for use by application callbacks.
enum ws_owire_error error
 The writer object's current error code.
uint64 auto_fragment
 Set to a nonzero value to enable automatic fragmentation.
int auto_mask
 Set to 1 to enable automatic masking of outgoing frames.

Detailed Description

Incremental writer for WebSocket wire protocol (out-bound).

See also:
ws_iwire
ws_owire_state
http://tools.ietf.org/html/rfc6455

Definition at line 82 of file owire.h.


Member Data Documentation

void(* ws_owire::accept_content)(struct ws_owire *wire, const void *data, uint64 size)

Called to signal that some data should be transferred.

Parameters:
wireThe current writer state.
dataArray of bytes to be transferred to the peer. Accessing past size bytes in this array results in undefined behavior.
sizeNumber of bytes in data the application must send.
See also:
baton

Definition at line 95 of file owire.h.

Set to a nonzero value to enable automatic fragmentation.

Automatic fragmentation of messages is normally only used during testing. If set to any nonzero value, the writer will ensure that no data or text messages will contain fragments large than this size (control messages cannot be fragmented). To achieve this, the writer breaks up large messages into chuncks of at most auto_fragment bytes in size.

Definition at line 162 of file owire.h.

Set to 1 to enable automatic masking of outgoing frames.

Clients are required to mask all outgoing frames and should enable automatic masking for the higher-level writer API functions. Servers must never enable automatic masking.

Definition at line 172 of file owire.h.

External state reserved for use by application callbacks.

See also:
accept_content()

Definition at line 125 of file owire.h.

The writer object's current error code.

This field should be considered as read-only, and must not be changed by applications. If paranoid, it should be checked after the call to each method. However, errors are only signaled when the object is misused and cannot be triggered by use of the higher-level writer API functions. Thus, once an application has been debugged, checking the error code after each call is unnecessary.

Definition at line 149 of file owire.h.

External state reserved for use by application callbacks.

This pointer is typically used to refer to the stateful pseudo random number generator that generates mask for the writer.

See also:
rand()

Definition at line 136 of file owire.h.

void(* ws_owire::rand)(struct ws_owire *wire, uint8 mask[4])

Called to signal that a mask must be generated.

Parameters:
wireThe current writer state.
mask4-byte array to fill in with random values.

This method is invoked each time a masked frame is sent. This can either happend when using auto_mask, or when ws_owire_mask() is called to manually add a mask.

By default, this callback invokes the standard library rand() to generated masks. You should set this to a cryptographically secure random number generator. Also, care should be taken for thread safety in threaded applications since the standard library rand() implementation is not guaranteed to be thread-safe.

See also:
prng
auto_mask
ws_owire_mask()

Definition at line 117 of file owire.h.


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