- /* tell the library what debug level to emit and to send it to syslog */
- lws_set_log_level(debug_level, lwsl_emit_syslog);
-
- lwsl_notice("libwebsockets test server libevent - license LGPL2.1+SLE\n");
- lwsl_notice("(C) Copyright 2010-2016 Andy Green <andy@warmcat.com>\n");
-
- printf("Using resource path \"%s\"\n", resource_path);
-
- info.iface = iface;
- info.protocols = protocols;
- info.extensions = exts;
-
- info.ssl_cert_filepath = NULL;
- info.ssl_private_key_filepath = NULL;
-
- if (use_ssl) {
- if (strlen(resource_path) > sizeof(cert_path) - 32) {
- lwsl_err("resource path too long\n");
- return -1;
- }
- sprintf(cert_path, "%s/libwebsockets-test-server.pem",
- resource_path);
- if (strlen(resource_path) > sizeof(key_path) - 32) {
- lwsl_err("resource path too long\n");
- return -1;
- }
- sprintf(key_path, "%s/libwebsockets-test-server.key.pem",
- resource_path);
-
- info.ssl_cert_filepath = cert_path;
- info.ssl_private_key_filepath = key_path;
-
- opts |= LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
- }
- info.gid = -1;
- info.uid = -1;
- info.max_http_header_pool = 1;
- info.options = opts | LWS_SERVER_OPTION_LIBEVENT;
-
- context = lws_create_context(&info);
- if (context == NULL) {
- lwsl_err("libwebsocket init failed\n");
- return -1;
- }
-
- /*
- * this shows how to override the lws file operations. You don't need
- * to do any of this unless you have a reason (eg, want to serve
- * compressed files without decompressing the whole archive)
- */
- /* stash original platform fops */
- fops_plat = *(lws_get_fops(context));
- /* override the active fops */
- lws_get_fops(context)->open = test_server_fops_open;
-
- // Don't use the default Signal Event Watcher & Handler
- lws_event_sigint_cfg(context, 0, NULL);
- // Initialize the LWS with libevent loop
- lws_event_initloop(context, event_base_loop, 0);
-
- timeout_watcher = evtimer_new(event_base_loop, ev_timeout_cb, NULL);
- struct timeval tv = {0, 50000};
- evtimer_add(timeout_watcher, &tv);
- event_base_dispatch(event_base_loop);
-
- lws_context_destroy(context);
- lwsl_notice("libwebsockets-test-server exited cleanly\n");
+ /* tell the library what debug level to emit and to send it to syslog */
+ lws_set_log_level(debug_level, lwsl_emit_syslog);
+
+ lwsl_notice("libwebsockets test server libevent - license LGPL2.1+SLE\n");
+ lwsl_notice("(C) Copyright 2010-2016 Andy Green <andy@warmcat.com>\n");
+
+ printf("Using resource path \"%s\"\n", resource_path);
+
+ info.iface = iface;
+ info.protocols = protocols;
+ info.extensions = exts;
+
+ info.ssl_cert_filepath = NULL;
+ info.ssl_private_key_filepath = NULL;
+
+ if (use_ssl) {
+ if (strlen(resource_path) > sizeof(cert_path) - 32) {
+ lwsl_err("resource path too long\n");
+ return -1;
+ }
+ sprintf(cert_path, "%s/libwebsockets-test-server.pem",
+ resource_path);
+ if (strlen(resource_path) > sizeof(key_path) - 32) {
+ lwsl_err("resource path too long\n");
+ return -1;
+ }
+ sprintf(key_path, "%s/libwebsockets-test-server.key.pem",
+ resource_path);
+
+ info.ssl_cert_filepath = cert_path;
+ info.ssl_private_key_filepath = key_path;
+
+ opts |= LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
+ }
+ info.gid = -1;
+ info.uid = -1;
+ info.max_http_header_pool = 1;
+ info.options = opts | LWS_SERVER_OPTION_LIBEVENT;
+
+ context = lws_create_context(&info);
+ if (context == NULL) {
+ lwsl_err("libwebsocket init failed\n");
+ return -1;
+ }
+
+ /*
+ * this shows how to override the lws file operations. You don't need
+ * to do any of this unless you have a reason (eg, want to serve
+ * compressed files without decompressing the whole archive)
+ */
+ /* stash original platform fops */
+ fops_plat = *(lws_get_fops(context));
+ /* override the active fops */
+ lws_get_fops(context)->open = test_server_fops_open;
+
+ // Don't use the default Signal Event Watcher & Handler
+ lws_event_sigint_cfg(context, 0, NULL);
+ // Initialize the LWS with libevent loop
+ lws_event_initloop(context, event_base_loop, 0);
+
+ timeout_watcher = event_new(event_base_loop, -1, EV_PERSIST, ev_timeout_cb, NULL);
+ struct timeval tv = {0, 50000};
+ evtimer_add(timeout_watcher, &tv);
+ event_base_dispatch(event_base_loop);
+
+ lws_context_destroy(context);
+ lwsl_notice("libwebsockets-test-server exited cleanly\n");