Unseen Academy

Single threaded mongoose

I really like the idea to include a web server into own applications as debug interface for the developer. There are some libraries around, but I took mongoose (one header file, one source file) and worked with that program. The problem with mongoose is the multiple workers solution used to provide the content fastly also on multi core machine, but I didn't want to syncronise the access to my internal data structures between my program and the web worker threads, hence I modified mongoose to be single threaded (which is no problem when only one or two persons connect to the program).

You can finde the source code here on my bitbucket account. Included is a c++ version of ngtemplate to generate web pages from templates. Combined with a instant asset reloading system it's really a great system to build a debugging interface!

Using the library is simple:
const char *options[] = { "listening_ports", "8080", "debug_single_threaded", "yes", NULL }; context = mg_start(&eventHandler, nullptr, options); ... while(appRunning) { ... mg_poll_single_threaded(context); } ... mg_stop(context);