|
cwebs 0.2.1
WebSocket wire protocol
|
Web Socket wire protocol (in-bound) for C. More...
#include "types.h"Go to the source code of this file.
Classes | |
| struct | ws_iwire |
| Incremental parser for WebSocket wire protocol (in-bound). More... | |
Functions | |
| void | ws_iwire_init (struct ws_iwire *stream) |
| Initialize a parser. | |
| uint64 | ws_iwire_feed (struct ws_iwire *stream, const void *data, uint64 size) |
| Consume available data and trigger appropriate application callbacks. | |
| int | ws_iwire_mask (const struct ws_iwire *stream) |
| Check if the current frame is masked. | |
| int | ws_iwire_last (const struct ws_iwire *stream) |
| Check if the current frame is the message's last fragment. | |
| int | ws_iwire_ping (const struct ws_iwire *stream) |
| Check if the current frame is a ping message. | |
| int | ws_iwire_pong (const struct ws_iwire *stream) |
| Check if the current frame is a pong message. | |
| int | ws_iwire_text (const struct ws_iwire *stream) |
| Check if the current fragment is a UTF-8 text message. | |
| int | ws_iwire_data (const struct ws_iwire *stream) |
| Check if the current fragment is a binary message. | |
| int | ws_iwire_dead (const struct ws_iwire *stream) |
| Check if the current fragment is a close frame. | |
Web Socket wire protocol (in-bound) for C.
Definition in file iwire.h.
| int ws_iwire_data | ( | const struct ws_iwire * | stream | ) |
Check if the current fragment is a binary message.
| stream | The current parser state. |
ws_iwire::new_message callback because that callback is triggered before the message frame is parsed.| int ws_iwire_dead | ( | const struct ws_iwire * | stream | ) |
Check if the current fragment is a close frame.
| stream | The current parser state. |
Closing frames may supply a 16-bit unsigned integer and a UTF-8 payload to describe the reason for closing the connection. Interpretation of the status code and error text are up to the application. The WebSocket specification does not require the UTF-8 error text to be human readable.
ws_iwire::new_message callback because that callback is triggered before the message frame is parsed.Consume available data and trigger appropriate application callbacks.
| stream | The current parser state. |
| data | Array of bytes available to the parser. Accessing past size bytes in this array results in undefined behavior. |
| size | Number of bytes in data the state can process. |
This function always consumes as much data as it can. Therefore, a single invocation of this function may happend to parse many messages if lots of data has accumulated in the application's buffers. It is recommended that the application call this method often to ensure prompt responses and low latency.
| void ws_iwire_init | ( | struct ws_iwire * | stream | ) |
| int ws_iwire_last | ( | const struct ws_iwire * | stream | ) |
Check if the current frame is the message's last fragment.
| stream | The current parser state. |
ws_iwire::new_message callback because that callback is triggered before the message frame is parsed.| int ws_iwire_mask | ( | const struct ws_iwire * | stream | ) |
Check if the current frame is masked.
| stream | The current parser state. |
ws_iwire::new_message callback because that callback is triggered before the message frame is parsed.| int ws_iwire_ping | ( | const struct ws_iwire * | stream | ) |
Check if the current frame is a ping message.
| stream | The current parser state. |
The application should respond with a pong message containing identical data. Ping pong messages help reset timeouts, ensuring the connection is not killed until either peer decides to close it.
ws_iwire::new_message callback because that callback is triggered before the message frame is parsed.| int ws_iwire_pong | ( | const struct ws_iwire * | stream | ) |
Check if the current frame is a pong message.
| stream | The current parser state. |
The application should validate that the pong message contains data identical to that sent in a ping message. Note that the WebSocket specification allows unsolicited pong messages for implementation of unidirectional heartbeats. This may be useful if the application wants to test the socket for writability, which is the only reliable way to determine if a TCP connection has been broken).
ws_iwire::new_message callback because that callback is triggered before the message frame is parsed.| int ws_iwire_text | ( | const struct ws_iwire * | stream | ) |
Check if the current fragment is a UTF-8 text message.
| stream | The current parser state. |
ws_iwire::new_message callback because that callback is triggered before the message frame is parsed.