wsi->pings_vs_pongs = 0;
wsi->protocol = NULL;
wsi->pending_timeout = NO_PENDING_TIMEOUT;
+ wsi->count_active_extensions = 0;
#ifdef LWS_OPENSSL_SUPPORT
wsi->use_ssl = ssl_connection;
#endif
memset(new_wsi, 0, sizeof (struct libwebsocket));
new_wsi->sock = accept_fd;
+ new_wsi->count_active_extensions = 0;
new_wsi->pending_timeout = NO_PENDING_TIMEOUT;
#ifdef LWS_OPENSSL_SUPPORT
new_wsi->sock = accept_fd;
new_wsi->mode = LWS_CONNMODE_BROADCAST_PROXY;
new_wsi->state = WSI_STATE_ESTABLISHED;
+ new_wsi->count_active_extensions = 0;
/* note which protocol we are proxying */
new_wsi->protocol_index_for_broadcast_proxy =
wsi->protocol_index_for_broadcast_proxy;
struct libwebsocket_context *
libwebsocket_create_context(int port, const char *interf,
struct libwebsocket_protocols *protocols,
+ struct libwebsocket_extension *extensions,
const char *ssl_cert_filepath,
const char *ssl_private_key_filepath,
int gid, int uid, unsigned int options)
context->http_proxy_address[0] = '\0';
context->options = options;
context->fds_count = 0;
+ context->extensions = extensions;
#ifdef WIN32
context->fd_random = 0;
wsi = malloc(sizeof(struct libwebsocket));
memset(wsi, 0, sizeof (struct libwebsocket));
wsi->sock = sockfd;
+ wsi->count_active_extensions = 0;
wsi->mode = LWS_CONNMODE_SERVER_LISTENER;
insert_wsi(context, wsi);
memset(wsi, 0, sizeof (struct libwebsocket));
wsi->sock = fd;
wsi->mode = LWS_CONNMODE_BROADCAST_PROXY_LISTENER;
+ wsi->count_active_extensions = 0;
/* note which protocol we are proxying */
wsi->protocol_index_for_broadcast_proxy =
context->count_protocols;
int protocol_index;
};
+/**
+ * struct libwebsocket_extension - An extension we know how to cope with
+ *
+ * @name: Formal extension name, eg, "deflate-stream"
+ * @callback: Service callback
+ * @per_session_data_size: Libwebsockets will auto-malloc this much
+ * memory for the use of the extension, a pointer
+ * to it comes in the @user callback parameter
+ */
+
+struct libwebsocket_extension {
+ const char *name;
+ int (*callback)(struct libwebsocket_context *context,
+ struct libwebsocket *wsi,
+ enum libwebsocket_callback_reasons reason, void *user,
+ void *in, size_t len);
+ size_t per_session_data_size;
+};
+
+
+
extern struct libwebsocket_context *
libwebsocket_create_context(int port, const char * interf,
struct libwebsocket_protocols *protocols,
+ struct libwebsocket_extension *extensions,
const char *ssl_cert_filepath,
const char *ssl_private_key_filepath, int gid, int uid,
unsigned int options);
#define MAX_USER_RX_BUFFER 4096
#define MAX_BROADCAST_PAYLOAD 2048
#define LWS_MAX_PROTOCOLS 10
+#define LWS_MAX_EXTENSIONS_ACTIVE 10
#define SPEC_LATEST_SUPPORTED 6
#define MAX_WEBSOCKET_04_KEY_LEN 128
#endif
struct libwebsocket_protocols *protocols;
int count_protocols;
+ struct libwebsocket_extension *extensions;
};
struct libwebsocket {
const struct libwebsocket_protocols *protocol;
+ const struct libwebsocket_extension *
+ active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
+ void * active_extensions_user[LWS_MAX_EXTENSIONS_ACTIVE];
+ int count_active_extensions;
enum lws_connection_states state;
(<i>int</i> <b>port</b>,
<i>const char *</i> <b>interf</b>,
<i>struct libwebsocket_protocols *</i> <b>protocols</b>,
+<i>struct libwebsocket_extension *</i> <b>extensions</b>,
<i>const char *</i> <b>ssl_cert_filepath</b>,
<i>const char *</i> <b>ssl_private_key_filepath</b>,
<i>int</i> <b>gid</b>,
allows as many protocols as you like to be handled by one server.
</blockquote>
<hr>
+<h2>struct libwebsocket_extension - An extension we know how to cope with</h2>
+<b>struct libwebsocket_extension</b> {<br>
+ <i>const char *</i> <b>name</b>;<br>
+ <i>int (*</i><b>callback</b>) <i>(struct libwebsocket_context *context,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user,void *in, size_t len)</i>;<br>
+ <i>size_t</i> <b>per_session_data_size</b>;<br>
+};<br>
+<h3>Members</h3>
+<dl>
+<dt><b>name</b>
+<dd>Formal extension name, eg, "deflate-stream"
+<dt><b>callback</b>
+<dd>Service callback
+<dt><b>per_session_data_size</b>
+<dd>Libwebsockets will auto-malloc this much
+memory for the use of the extension, a pointer
+to it comes in the <tt><b>user</b></tt> callback parameter
+</dl>
+<hr>
*/
context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
- protocols, NULL, NULL, -1, -1, 0);
+ protocols, NULL,
+ NULL, NULL, -1, -1, 0);
if (context == NULL) {
fprintf(stderr, "Creating libwebsocket context failed\n");
return 1;
screen_width = w.ws_col;
context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,
- protocols, NULL, NULL, -1, -1, 0);
+ protocols, NULL,
+ NULL, NULL, -1, -1, 0);
if (context == NULL) {
fprintf(stderr, "Creating libwebsocket context failed\n");
return 1;
cert_path = key_path = NULL;
context = libwebsocket_create_context(port, interface, protocols,
+ NULL,
cert_path, key_path, -1, -1, opts);
if (context == NULL) {
fprintf(stderr, "libwebsocket init failed\n");
cert_path = key_path = NULL;
context = libwebsocket_create_context(port, interface, protocols,
+ NULL,
cert_path, key_path, -1, -1, opts);
if (context == NULL) {
fprintf(stderr, "libwebsocket init failed\n");