|
cwebs 0.2.1
WebSocket wire protocol
|
Web Socket wire protocol (out-bound) for C. More...
#include "types.h"Go to the source code of this file.
Classes | |
| struct | ws_owire |
| Incremental writer for WebSocket wire protocol (out-bound). More... | |
Enumerations | |
| enum | ws_owire_error { ws_owire_eok, ws_owire_enotready } |
| Writer error codes. More... | |
Functions | |
| void | ws_owire_init (struct ws_owire *stream) |
| Initialize a writer. | |
| void | ws_owire_new_message (struct ws_owire *stream) |
| Start a new message. | |
| void | ws_owire_end_message (struct ws_owire *stream) |
| End a message, clearing the state for the next message. | |
| void | ws_owire_new_frame (struct ws_owire *stream, uint64 size) |
| Start a frame with a size byte payload. | |
| void | ws_owire_end_frame (struct ws_owire *stream) |
| End a frame, clearing the state for the next frame. | |
| void | ws_owire_last (struct ws_owire *stream) |
| Mark the current frame as the last fragment in a message. | |
| void | ws_owire_eval (struct ws_owire *stream, uint8 eval) |
| Set the WebSocket extension code. | |
| void | ws_owire_code (struct ws_owire *stream, uint8 code) |
| Set the WebSocket message opcode. | |
| void | ws_owire_mask (struct ws_owire *stream) |
| Mark the fragment as masked. | |
| uint64 | ws_owire_feed (struct ws_owire *stream, const void *data, uint64 size) |
| Add data to the application payload. | |
| void | ws_owire_ping (struct ws_owire *stream) |
| Mark the current frame as a ping message. | |
| void | ws_owire_pong (struct ws_owire *stream) |
| Mark the current frame as a pong message. | |
| void | ws_owire_text (struct ws_owire *stream) |
| Mark the current frame as a text message. | |
| void | ws_owire_data (struct ws_owire *stream) |
| Mark the current frame as a binary data message. | |
| void | ws_owire_kill (struct ws_owire *stream) |
| Mark the current frame as an end-of-stream control message. | |
| void | ws_owire_put_text (struct ws_owire *stream, const void *data, uint64 size) |
| Send a full text message in a single call. | |
| void | ws_owire_put_data (struct ws_owire *stream, const void *data, uint64 size) |
| Send a full binary data message in a single call. | |
| void | ws_owire_put_ping (struct ws_owire *stream, const void *data, uint64 size) |
| Send a full ping message in a single call. | |
| void | ws_owire_put_pong (struct ws_owire *stream, const void *data, uint64 size) |
| Send a full pong message in a single call. | |
| void | ws_owire_put_kill (struct ws_owire *stream, const void *data, uint64 size) |
| Send a full end-of-stream message in a single call. | |
Web Socket wire protocol (out-bound) for C.
Definition in file owire.h.
| enum ws_owire_error |
Set the WebSocket message opcode.
| stream | The curernt writer state. |
| code | The message opcode. |
This method should not be used unless the WebSocket protocol specification is updated add new control message codes before the library is updated to implement the extended specification. Use the explicit named functions for application clarity.
| void ws_owire_data | ( | struct ws_owire * | stream | ) |
Mark the current frame as a binary data message.
| stream | The current writer state. |
| void ws_owire_end_frame | ( | struct ws_owire * | stream | ) |
End a frame, clearing the state for the next frame.
| stream | Current writer state. |
| void ws_owire_end_message | ( | struct ws_owire * | stream | ) |
End a message, clearing the state for the next message.
| stream | Current writer state. |
Add data to the application payload.
| stream | The current writer state. |
| data | Array of bytes to write. Accessing past size bytes in this array results in undefined behavior. |
| size | Number of bytes in data to forward. |
You may invoke this function multiple times to reach the total fragment payload size given to ws_owire_new_frame().
| void ws_owire_init | ( | struct ws_owire * | stream | ) |
| void ws_owire_kill | ( | struct ws_owire * | stream | ) |
Mark the current frame as an end-of-stream control message.
| stream | The current frame state. |
Control messages cannot be fragmented. Always mark end-of-stream messages with ws_owire_last().
| void ws_owire_last | ( | struct ws_owire * | stream | ) |
| void ws_owire_mask | ( | struct ws_owire * | stream | ) |
Mark the fragment as masked.
| stream | The current writer state. |
This will indirectly invoke the ws_owire::rand callback to generate a random mask.
Start a frame with a size byte payload.
| stream | Current writer state. |
| size | Size of the frame payload, in bytes. |
| void ws_owire_new_message | ( | struct ws_owire * | stream | ) |
| void ws_owire_ping | ( | struct ws_owire * | stream | ) |
Mark the current frame as a ping message.
| stream | The current frame state. |
Control messages cannot be fragmented. Always mark ping messages with ws_owire_last().
| void ws_owire_pong | ( | struct ws_owire * | stream | ) |
Mark the current frame as a pong message.
| stream | The current frame state. |
Control messages cannot be fragmented. Always mark pong messages with ws_owire_last().
Send a full binary data message in a single call.
| stream | The current writer state. |
| data | Payload data. |
| size | Payload size, in bytes. |
Send a full end-of-stream message in a single call.
| stream | The current writer state. |
| data | Payload data. |
| size | Payload size, in bytes. |
The payload must be UTF-8 encoded text.
ws_owire::auto_fragment setting.Send a full ping message in a single call.
| stream | The current writer state. |
| data | Payload data. |
| size | Payload size, in bytes. |
ws_owire::auto_fragment setting. Send a full pong message in a single call.
| stream | The current writer state. |
| data | Payload data. |
| size | Payload size, in bytes. |
ws_owire::auto_fragment setting. Send a full text message in a single call.
| stream | The current writer state. |
| data | Payload data. |
| size | Payload size, in bytes. |
| void ws_owire_text | ( | struct ws_owire * | stream | ) |
Mark the current frame as a text message.
| stream | The current writer state. |