libonion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
websocket.h File Reference
#include <stddef.h>
#include <stdarg.h>
#include "types.h"

Functions

onion_websocketonion_websocket_new (onion_request *req, onion_response *res)
 Get the current websocket handler, or create it. If not a websocket request, returns NULL.
void onion_websocket_free (onion_websocket *ws)
 When freed, the callback is invoked with a negative data length.
void onion_websocket_close (onion_websocket *ws, const char *status)
 Closes the websocket sending the close opcode (8)
void onion_websocket_set_callback (onion_websocket *ws, onion_websocket_callback_t cb)
void onion_websocket_set_userdata (onion_websocket *ws, void *userdata, void(*free_userdata)(void *))
int onion_websocket_read (onion_websocket *ws, char *buffer, size_t len)
int onion_websocket_write (onion_websocket *ws, const char *buffer, size_t len)
int onion_websocket_vprintf (onion_websocket *ws, const char *fmt, va_list args) __attribute__((format(printf
int int onion_websocket_printf (onion_websocket *ws, const char *str,...) __attribute__((format(printf
int int onion_connection_status onion_websocket_call (onion_websocket *ws)
void onion_websocket_set_opcode (onion_websocket *ws, onion_websocket_opcode opcode)
 Sets the opcode for the websocketThis can be called before writes to change the meaning of the write.
onion_websocket_opcode onion_websocket_get_opcode (onion_websocket *ws)
 Returns current in use opcodes.

Function Documentation

int int onion_connection_status onion_websocket_call ( onion_websocket ws)
void onion_websocket_close ( onion_websocket ws,
const char *  status 
)

Closes the websocket sending the close opcode (8)

References onion_websocket_set_opcode(), onion_websocket_t::onion_websocket_write(), and OWS_CONNECTION_CLOSE.

void onion_websocket_free ( onion_websocket ws)

When freed, the callback is invoked with a negative data length.

onion_websocket* onion_websocket_new ( onion_request req,
onion_response res 
)

Get the current websocket handler, or create it. If not a websocket request, returns NULL.

int int onion_websocket_printf ( onion_websocket ws,
const char *  str,
  ... 
)
int onion_websocket_read ( onion_websocket ws,
char *  buffer,
size_t  len 
)
void onion_websocket_set_callback ( onion_websocket ws,
onion_websocket_callback_t  cb 
)
void onion_websocket_set_userdata ( onion_websocket ws,
void *  userdata,
void(*)(void *)  free_userdata 
)
int onion_websocket_vprintf ( onion_websocket ws,
const char *  fmt,
va_list  args 
)
int onion_websocket_write ( onion_websocket ws,
const char *  buffer,
size_t  len 
)