|
cwebs 0.2.1
WebSocket wire protocol
|
Incremental writer for WebSocket wire protocol (out-bound). More...
#include <owire.h>
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. | |
Incremental writer for WebSocket wire protocol (out-bound).
| void(* ws_owire::accept_content)(struct ws_owire *wire, const void *data, uint64 size) |
Called to signal that some data should be transferred.
| wire | The current writer state. |
| data | Array of bytes to be transferred to the peer. Accessing past size bytes in this array results in undefined behavior. |
| size | Number of bytes in data the application must send. |
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.
| void* ws_owire::baton |
External state reserved for use by application callbacks.
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.
| void* ws_owire::prng |
| void(* ws_owire::rand)(struct ws_owire *wire, uint8 mask[4]) |
Called to signal that a mask must be generated.
| wire | The current writer state. |
| mask | 4-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.