libevws  0.1
WebSocketserverlibrary
 All Files Functions Typedefs Enumerations
Typedefs | Enumerations | Functions
evws.h File Reference

Go to the source code of this file.

Typedefs

typedef void(* evwsconn_message_cb )(struct evwsconn *conn, enum evws_data_type, const unsigned char *data, int len, void *user_data)
 
typedef void(* evwsconn_close_cb )(struct evwsconn *conn, void *user_data)
 
typedef void(* evwsconn_error_cb )(struct evwsconn *conn, void *user_data)
 

Enumerations

enum  evws_data_type { EVWS_DATA_TEXT = 0, EVWS_DATA_BINARY = 1 }
 

Functions

void evwsconn_set_cbs (struct evwsconn *conn, evwsconn_message_cb message_cb, evwsconn_close_cb close_cb, evwsconn_error_cb error_cb, void *user_data)
 
void evwsconn_send_message (struct evwsconn *conn, enum evws_data_type data_type, const unsigned char *data, int len)
 
const char * evwsconn_get_subprotocol (struct evwsconn *conn)
 
void evwsconn_send_close (struct evwsconn *conn)
 
void evwsconn_free (struct evwsconn *conn)
 

Typedef Documentation

typedef void(* evwsconn_close_cb)(struct evwsconn *conn, void *user_data)

A callback invoked when the WebSocket connection has been closed.

Parameters
connThe evwsconn that received the data
user_dataThe user-supplied pointer passed to evwsconn_set_cbs
typedef void(* evwsconn_error_cb)(struct evwsconn *conn, void *user_data)

A callback invoked when an unrecoverable error has occured on the WebSocket connection.

Parameters
connThe evwsconn that received the data
user_dataThe user-supplied pointer passed to evwsconn_set_cbs
typedef void(* evwsconn_message_cb)(struct evwsconn *conn, enum evws_data_type, const unsigned char *data, int len, void *user_data)

A callback invoked when a new message been received on the WebSocket connection

Parameters
connThe evwsconn that received the data
data_typeThe type of data received
dataThe data received
lenThe length of the data
user_dataThe user-supplied pointer passed to evwsconn_set_cbs

Enumeration Type Documentation

Types of data in messages sent and received by a WebSocket connection

Function Documentation

void evwsconn_free ( struct evwsconn *  conn)

Disable and deallocate an evwsconn

const char* evwsconn_get_subprotocol ( struct evwsconn *  conn)

Get the subprotocol used for this connection.

Parameters
connThe evwsconn for which to get the subprotocol
void evwsconn_send_close ( struct evwsconn *  conn)

Send a close message to client and, once sent, close the connection.

NOTE: evwsconn_close_cb() will still be called when the connection is closed. Calling evwsconn_free() before that callback will prevent the close message from being sent as required to cleanly close a WebSocket connection.

void evwsconn_send_message ( struct evwsconn *  conn,
enum evws_data_type  data_type,
const unsigned char *  data,
int  len 
)

Send a new message on the WebSocket connection.

Parameters
connThe evwsconn on which to send the message
data_typeThe type of data to be sent
dataThe data to send
lenThe length of the data
void evwsconn_set_cbs ( struct evwsconn *  conn,
evwsconn_message_cb  message_cb,
evwsconn_close_cb  close_cb,
evwsconn_error_cb  error_cb,
void *  user_data 
)

Sets (or changes) callbacks on a WebSocket connection.

Parameters
connThe evwsconn that received the data
message_cbMessage (new data received) callback
close_cbClose callback
error_cbError callback
user_dataThe user-supplied pointer passed to evwsconn_set_cbs