#include <event2/listener.h>
Go to the source code of this file.
|
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) |
|
|
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 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
-
listener | The evwsconnlistener |
conn | The new evwsconn struct for the new connection |
address | The source address of the connection |
socklen | The length of the address |
user_data | The 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
-
listener | The evwsconnlistener |
user_data | The pointer passed to evwsconnlistener_new |
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
-
base | The event base from libevent |
cb | The connection callback as defined above |
user_data | A user-supplied pointer that will be passed to the callbacks |
flags | Any number of LEV_OPT_* flags from libevent |
backlog | Passed to the listen() call to determine the length of the acceptable connection backlog. Set to -1 for reasonable default. |
subprotocols | An array of subprotocols that are supported by the server. If no subprotocols are supported, NULL may be sent. |
fd | The 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
-
base | The event base from libevent |
cb | The connection callback as defined above |
user_data | A user-supplied pointer that will be passed to the callbacks |
flags | Any number of LEV_OPT_* flags from libevent |
backlog | Passed to the listen() call to determine the length of the acceptable connection backlog. Set to -1 for reasonable default. |
subprotocols | An array of subprotocols that are supported by the server. If no subprotocols are supported, NULL may be sent. |
addr | The address to listen for connections on. |
socklen | The 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.
Set an evwsconnlistener's error callback.