libevws  0.1
WebSocketserverlibrary
 All Files Functions Typedefs Enumerations
Typedefs | Functions
wslistener.h File Reference
#include <event2/listener.h>

Go to the source code of this file.

Typedefs

typedef void(* evwsconnlistener_cb )(struct evwsconnlistener *listener, struct evwsconn *conn, struct sockaddr *address, int socklen, void *user_data)
 
typedef void(* evwsconnlistener_errorcb )(struct evwsconnlistener *listener, void *user_data)
 

Functions

struct evwsconnlistener * evwsconnlistener_new (struct event_base *base, evwsconnlistener_cb cb, void *user_data, unsigned flags, int backlog, const char *subprotocols[], evutil_socket_t fd)
 
struct evwsconnlistener * evwsconnlistener_new_bind (struct event_base *base, evwsconnlistener_cb cb, void *user_data, unsigned flags, int backlog, const char *subprotocols[], const struct sockaddr *addr, int socklen)
 
void evwsconnlistener_free (struct evwsconnlistener *levws)
 
struct evconnlistener * evconnlistener_get_evconnlistener (struct evwsconnlistener *levws)
 
void evwsconnlistener_set_cb (struct evwsconnlistener *levws, evwsconnlistener_cb cb, void *user_data)
 
void evwsconnlistener_set_error_cb (struct evwsconnlistener *levws, evwsconnlistener_errorcb errorcb)
 

Typedef Documentation

typedef void(* evwsconnlistener_cb)(struct evwsconnlistener *listener, struct evwsconn *conn, struct sockaddr *address, int socklen, void *user_data)

A callback invoked when the listener has a new WebSocket connection and the handshake has been successfully completed.

NOTE: The callback must take ownership of the evwsconn struct and deallocate it (via evwsconn_free()) when done with it.

Parameters
listenerThe evwsconnlistener
connThe new evwsconn struct for the new connection
addressThe source address of the connection
socklenThe length of the address
user_dataThe pointer passed to evwsconnlistener_new
typedef void(* evwsconnlistener_errorcb)(struct evwsconnlistener *listener, void *user_data)

A callback invoked when an error occurs on the listener.

Parameters
listenerThe evwsconnlistener
user_dataThe pointer passed to evwsconnlistener_new

Function Documentation

struct evconnlistener* evconnlistener_get_evconnlistener ( struct evwsconnlistener *  levws)

Return an evwsconnlistener's associated evconnlistener.

void evwsconnlistener_free ( struct evwsconnlistener *  levws)

Disable and deallocate an evwsconnlistener.

struct evwsconnlistener* evwsconnlistener_new ( struct event_base *  base,
evwsconnlistener_cb  cb,
void *  user_data,
unsigned  flags,
int  backlog,
const char *  subprotocols[],
evutil_socket_t  fd 
)

Allocate a new evwsconnlistener object to listen for incoming WebSocket connections a given file descriptor.

Parameters
baseThe event base from libevent
cbThe connection callback as defined above
user_dataA user-supplied pointer that will be passed to the callbacks
flagsAny number of LEV_OPT_* flags from libevent
backlogPassed to the listen() call to determine the length of the acceptable connection backlog. Set to -1 for reasonable default.
subprotocolsAn array of subprotocols that are supported by the server. If no subprotocols are supported, NULL may be sent.
fdThe file descriptor to listen on. It must be a non-blocking file descriptor, and it should already be bound to an appropriate port and address.
struct evwsconnlistener* evwsconnlistener_new_bind ( struct event_base *  base,
evwsconnlistener_cb  cb,
void *  user_data,
unsigned  flags,
int  backlog,
const char *  subprotocols[],
const struct sockaddr *  addr,
int  socklen 
)

Allocate a new evwsconnlistener object to listen for incoming WebSocket connections a given file descriptor.

Parameters
baseThe event base from libevent
cbThe connection callback as defined above
user_dataA user-supplied pointer that will be passed to the callbacks
flagsAny number of LEV_OPT_* flags from libevent
backlogPassed to the listen() call to determine the length of the acceptable connection backlog. Set to -1 for reasonable default.
subprotocolsAn array of subprotocols that are supported by the server. If no subprotocols are supported, NULL may be sent.
addrThe address to listen for connections on.
socklenThe length of the address.
void evwsconnlistener_set_cb ( struct evwsconnlistener *  levws,
evwsconnlistener_cb  cb,
void *  user_data 
)

Change the callback on the listener to cb and its user_data.

void evwsconnlistener_set_error_cb ( struct evwsconnlistener *  levws,
evwsconnlistener_errorcb  errorcb 
)

Set an evwsconnlistener's error callback.