All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Types | Public Member Functions | Data Fields
onion_websocket_t Struct Reference

Websocket data type, as returned by onion_websocket_new. More...

#include <types.h>

Public Types

enum  onion_websocket_opcode_e
 Types of fragments that websockets support. More...
typedef onion_connection_status(* onion_websocket_callback_t )(void *privdata, onion_websocket *ws, ssize_t data_ready_length)
 Prototype for websocket callbacks.

Public Member Functions

onion_websocketonion_websocket_new (onion_request *req, onion_response *res)
 Creates a websocket connection from the given request to the response.
void onion_websocket_free (onion_websocket *ws)
 Frees the websocket.
int onion_websocket_write (onion_websocket *ws, const char *buffer, size_t _len)
 Writes a fragment to the websocket.
int onion_websocket_read (onion_websocket *ws, char *buffer, size_t len)
 Reads some data from the websocket.
int onion_websocket_vprintf (onion_websocket *ws, const char *fmt, va_list args)
 Uses vprintf-style writing to the websocket.
int onion_websocket_printf (onion_websocket *ws, const char *fmt,...)
 Uses printf-style writing to the websocket.
void onion_websocket_set_callback (onion_websocket *ws, onion_websocket_callback_t cb)
 Sets the next callback to call if more data is available.
void onion_websocket_set_userdata (onion_websocket *ws, void *userdata, void(*free_userdata)(void *))
 Sets the userdata to use for this websocket connection.
onion_connection_status onion_websocket_call (onion_websocket *ws)
 Used internally when new data is ready on the websocket file descriptor.

Data Fields

onion_websocket_callback_t callback
 Associated request.
void * user_data
 Callback to call, if any, when new data is available.
void(* free_user_data )(void *)
int64_t data_left
char mask [4]
int8_t mask_pos
int8_t flags
onion_websocket_opcode opcode:4
 Defined at websocket.c.

Detailed Description

Websocket data type, as returned by onion_websocket_new.

FIXME: Some websocket description on how to use.

Ping requests (client->server) are handled internally. pong answers are not (server->client).

When a ping request is received, callback may be called with length=0, and no data waiting to be read.

Field Documentation

onion_websocket_callback_t onion_websocket_t::callback
int64_t onion_websocket_t::data_left
int8_t onion_websocket_t::flags
void(* onion_websocket_t::free_user_data)(void *)
char onion_websocket_t::mask[4]

Referenced by onion_websocket_read().

int8_t onion_websocket_t::mask_pos

Referenced by onion_websocket_read().

onion_websocket_opcode onion_websocket_t::opcode
onion_request* onion_websocket_t::req
void* onion_websocket_t::user_data

Callback to call, if any, when new data is available.

Referenced by onion_websocket_call(), onion_websocket_free(), onion_websocket_new(), and onion_websocket_set_userdata().

The documentation for this struct was generated from the following files: