libwebsockets
Lightweight C library for HTML5 websockets
lws_protocols Struct Reference

#include <lws-protocols-plugins.h>

Data Fields

const char * name
 
lws_callback_functioncallback
 
size_t per_session_data_size
 
size_t rx_buffer_size
 
unsigned int id
 
void * user
 
size_t tx_packet_size
 

Detailed Description

struct lws_protocols - List of protocols and handlers client or server supports.

Field Documentation

◆ callback

lws_callback_function* lws_protocols::callback

The service callback used for this protocol. It allows the service action for an entire protocol to be encapsulated in the protocol-specific callback

◆ id

unsigned int lws_protocols::id

ignored by lws, but useful to contain user information bound to the selected protocol. For example if this protocol was called "myprotocol-v2", you might set id to 2, and the user code that acts differently according to the version can do so by switch (wsi->a.protocol->id), user code might use some bits as capability flags based on selected protocol version, etc.

◆ name

const char* lws_protocols::name

Protocol name that must match the one given in the client Javascript new WebSocket(url, 'protocol') name.

◆ per_session_data_size

size_t lws_protocols::per_session_data_size

Each new connection using this protocol gets this much memory allocated on connection establishment and freed on connection takedown. A pointer to this per-connection allocation is passed into the callback in the 'user' parameter

◆ rx_buffer_size

size_t lws_protocols::rx_buffer_size

lws allocates this much space for rx data and informs callback when something came. Due to rx flow control, the callback may not be able to consume it all without having to return to the event loop. That is supported in lws.

If .tx_packet_size is 0, this also controls how much may be sent at once for backwards compatibility.

◆ tx_packet_size

size_t lws_protocols::tx_packet_size

0 indicates restrict send() size to .rx_buffer_size for backwards- compatibility. If greater than zero, a single send() is restricted to this amount and any remainder is buffered by lws and sent afterwards also in these size chunks. Since that is expensive, it's preferable to restrict one fragment you are trying to send to match this size.

◆ user

void* lws_protocols::user

ignored by lws, but user code can pass a pointer here it can later access from the protocol callback


The documentation for this struct was generated from the following file: