![]() |
libwebsockets
Lightweight C library for HTML5 websockets
|
Modules | |
plugin: generic-sessions | |
Data Structures | |
struct | lws_protocols |
struct | lws_plugin_capability |
struct | lws_plugin |
Typedefs | |
typedef int(* | lws_plugin_init_func) (struct lws_context *, struct lws_plugin_capability *) |
typedef int(* | lws_plugin_destroy_func) (struct lws_context *) |
Functions | |
LWS_VISIBLE LWS_EXTERN const struct lws_protocols * | lws_vhost_name_to_protocol (struct lws_vhost *vh, const char *name) |
LWS_VISIBLE LWS_EXTERN const struct lws_protocols * | lws_get_protocol (struct lws *wsi) |
LWS_VISIBLE LWS_EXTERN const struct lws_protocols * | lws_protocol_get (struct lws *wsi) LWS_WARN_DEPRECATED |
LWS_VISIBLE LWS_EXTERN void * | lws_protocol_vh_priv_zalloc (struct lws_vhost *vhost, const struct lws_protocols *prot, int size) |
LWS_VISIBLE LWS_EXTERN void * | lws_protocol_vh_priv_get (struct lws_vhost *vhost, const struct lws_protocols *prot) |
LWS_VISIBLE LWS_EXTERN int | lws_finalize_startup (struct lws_context *context) |
Protocols bind ws protocol names to a custom callback specific to that protocol implementaion.
A list of protocols can be passed in at context creation time, but it is also legal to leave that NULL and add the protocols and their callback code using plugins.
Plugins are much preferable compared to cut and pasting code into an application each time, since they can be used standalone.
LWS_VISIBLE LWS_EXTERN int lws_finalize_startup | ( | struct lws_context * | context | ) |
#include <lib/libwebsockets.h>
lws_finalize_startup() - drop initial process privileges
context | lws context |
This is called after the end of the vhost protocol initializations, but you may choose to call it earlier
LWS_VISIBLE LWS_EXTERN const struct lws_protocols* lws_get_protocol | ( | struct lws * | wsi | ) |
#include <lib/libwebsockets.h>
lws_get_protocol() - Returns a protocol pointer from a websocket connection.
wsi | pointer to struct websocket you want to know the protocol of |
Some apis can act on all live connections of a given protocol, this is how you can get a pointer to the active protocol if needed.
LWS_VISIBLE LWS_EXTERN const struct lws_protocols* lws_protocol_get | ( | struct lws * | wsi | ) |
#include <lib/libwebsockets.h>
lws_protocol_get() - deprecated: use lws_get_protocol
LWS_VISIBLE LWS_EXTERN void* lws_protocol_vh_priv_get | ( | struct lws_vhost * | vhost, |
const struct lws_protocols * | prot | ||
) |
#include <lib/libwebsockets.h>
lws_protocol_vh_priv_get() - retreive a protocol's per-vhost storage
vhost | vhost the instance is related to |
prot | protocol the instance is related to |
Recover a pointer to the allocated per-vhost storage for the protocol created by lws_protocol_vh_priv_zalloc() earlier
LWS_VISIBLE LWS_EXTERN void* lws_protocol_vh_priv_zalloc | ( | struct lws_vhost * | vhost, |
const struct lws_protocols * | prot, | ||
int | size | ||
) |
#include <lib/libwebsockets.h>
lws_protocol_vh_priv_zalloc() - Allocate and zero down a protocol's per-vhost storage
vhost | vhost the instance is related to |
prot | protocol the instance is related to |
size | bytes to allocate |
Protocols often find it useful to allocate a per-vhost struct, this is a helper to be called in the per-vhost init LWS_CALLBACK_PROTOCOL_INIT
LWS_VISIBLE LWS_EXTERN const struct lws_protocols* lws_vhost_name_to_protocol | ( | struct lws_vhost * | vh, |
const char * | name | ||
) |
#include <lib/libwebsockets.h>
lws_vhost_name_to_protocol() - get vhost's protocol object from its name
vh | vhost to search |
name | protocol name |
Returns NULL or a pointer to the vhost's protocol of the requested name