* MA 02110-1301 USA
*/
+#define DI_HANDLED_BY_PLUGIN
#include "test-server.h"
#include <uv.h>
{
}
+#define LWS_PLUGIN_STATIC
+#include "../plugins/protocol_dumb_increment.c"
+#include "../plugins/protocol_lws_mirror.c"
+#include "../plugins/protocol_lws_status.c"
+
/*
* This demo server shows how to use libwebsockets for one or more
* websocket protocols in the same server
PROTOCOL_DUMB_INCREMENT,
PROTOCOL_LWS_MIRROR,
+ PROTOCOL_LWS_STATUS,
/* always last */
DEMO_PROTOCOL_COUNT
sizeof (struct per_session_data__http), /* per_session_data_size */
0, /* max frame size / rx buffer */
},
- {
- "dumb-increment-protocol",
- callback_dumb_increment,
- sizeof(struct per_session_data__dumb_increment),
- 10,
- },
- {
- "lws-mirror-protocol",
- callback_lws_mirror,
- sizeof(struct per_session_data__lws_mirror),
- 128,
- },
- {
- "lws-status",
- callback_lws_status,
- sizeof(struct per_session_data__lws_status),
- 128,
- },
+ LWS_PLUGIN_PROTOCOL_DUMB_INCREMENT,
+ LWS_PLUGIN_PROTOCOL_MIRROR,
+ LWS_PLUGIN_PROTOCOL_LWS_STATUS,
{ NULL, NULL, 0, 0 } /* terminator */
};
lws_libuv_stop(context);
}
-static void
-uv_timeout_cb_dumb_increment(uv_timer_t *w
-#if UV_VERSION_MAJOR == 0
- , int status
-#endif
-)
-{
- lws_callback_on_writable_all_protocol(context,
- &protocols[PROTOCOL_DUMB_INCREMENT]);
-}
static struct option options[] = {
{ "help", no_argument, NULL, 'h' },
int foreign_libuv_loop = 0;
/* <--- only needed for foreign loop test --- */
#endif
- uv_timer_t timeout_watcher;
const char *iface = NULL;
char cert_path[1024];
char key_path[1024];
}
}
- uv_timer_init(lws_uv_getloop(context, 0), &timeout_watcher);
- uv_timer_start(&timeout_watcher, uv_timeout_cb_dumb_increment, 50, 50);
-
#if UV_VERSION_MAJOR > 0
if (foreign_libuv_loop) {
/*
uv_timer_stop(&timer_inner);
uv_close((uv_handle_t*)&timer_inner, timer_close_cb);
- /* stop the dumb increment timer */
- uv_timer_stop(&timeout_watcher);
lwsl_notice("Destroying lws context\n");
lwsl_notice("libwebsockets-test-server exited cleanly\n");
+ context = NULL;
+
return 0;
}