1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/lib/extension-x-google-mux.h
Andy Green a41314f3bf introduce x google mux very draft indeed
This is initial x-google-mux support.  It's disabled by default
since it's very pre-alpha.

1) To enable it, reconfigure with --enable-x-google-mux

2) It conflicts with deflate-stream, use the -u switch on
   the test client to disable deflate-stream

3) It deviates from the google standard by sending full
   headers in the addchannel subcommand rather than just
   changed ones from original connect

4) Quota is not implemented yet

5) Close of subchannel is not really implemented yet

6) Google opcode 0xf is changed to 0x7 to account for
   v7 protocol changes to opcode layout

However despite those caveats, in fact it can run the
test client reliably over one socket (both dumb-increment
and lws-mirror-protocol), you can open a browser on the
same test server too and see the circles, etc.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-23 10:00:03 +01:00

94 lines
2.3 KiB
C

#if 0
#ifdef WIN32
static
#else
static inline
#endif
void muxdebug(const char *format, ...)
{
va_list ap;
va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap);
}
#else
#ifdef WIN32
static
#else
static inline
#endif
void muxdebug(const char *format, ...)
{
}
#endif
#define MAX_XGM_SUBCHANNELS 8192
enum lws_ext_x_google_mux__parser_states {
LWS_EXT_XGM_STATE__MUX_BLOCK_1,
LWS_EXT_XGM_STATE__MUX_BLOCK_2,
LWS_EXT_XGM_STATE__ADDCHANNEL_LEN,
LWS_EXT_XGM_STATE__ADDCHANNEL_LEN16_1,
LWS_EXT_XGM_STATE__ADDCHANNEL_LEN16_2,
LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_1,
LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_2,
LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_3,
LWS_EXT_XGM_STATE__ADDCHANNEL_LEN32_4,
LWS_EXT_XGM_STATE__ADDCHANNEL_HEADERS,
LWS_EXT_XGM_STATE__FLOWCONTROL_1,
LWS_EXT_XGM_STATE__FLOWCONTROL_2,
LWS_EXT_XGM_STATE__FLOWCONTROL_3,
LWS_EXT_XGM_STATE__FLOWCONTROL_4,
LWS_EXT_XGM_STATE__DATA,
};
enum lws_ext_x_goole_mux__mux_opcodes {
LWS_EXT_XGM_OPC__DATA,
LWS_EXT_XGM_OPC__ADDCHANNEL,
LWS_EXT_XGM_OPC__DROPCHANNEL,
LWS_EXT_XGM_OPC__FLOWCONTROL,
LWS_EXT_XGM_OPC__RESERVED_4,
LWS_EXT_XGM_OPC__RESERVED_5,
LWS_EXT_XGM_OPC__RESERVED_6,
LWS_EXT_XGM_OPC__RESERVED_7,
};
/* one of these per context (server or client) */
struct lws_ext_x_google_mux_context {
/*
* these are listing physical connections, not children sharing a
* parent mux physical connection
*/
struct libwebsocket *wsi_muxconns[MAX_CLIENTS];
/*
* when this is < 2, we do not do any mux blocks
* just pure websockets
*/
int active_conns;
};
inline int use_mux_blocks(struct lws_ext_x_google_mux_context * mux_context) { \
return !!(mux_context->active_conns > 1); }
/* one of these per connection (server or client) */
struct lws_ext_x_google_mux_conn {
enum lws_ext_x_goole_mux__mux_opcodes block_subopcode;
int block_subchannel;
unsigned int length;
enum lws_ext_x_google_mux__parser_states state;
/* child points to the mux wsi using this */
struct libwebsocket *wsi_parent;
int subchannel;
struct libwebsocket *wsi_children[MAX_CLIENTS];
int count_children;
char awaiting_POLLOUT;
int count_children_needing_POLLOUT;
};
extern int
lws_extension_callback_x_google_mux(struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
void *user, void *in, size_t len);