web_engine::web_engine(emu_options &options) : m_options(options), m_machine(NULL), m_ctx(NULL), m_lastupdatetime(0), m_exiting_core(false) { struct mg_callbacks callbacks; // List of options. Last element must be NULL. const char *web_options[] = { "listening_ports", options.http_port(), "document_root", options.http_path(), NULL }; // Prepare callbacks structure. memset(&callbacks, 0, sizeof(callbacks)); callbacks.begin_request = begin_request_handler_static; callbacks.websocket_ready = websocket_ready_handler_static; callbacks.websocket_data = websocket_data_handler_static; callbacks.http_error = begin_http_error_handler_static; // Start the web server. if (m_options.http()) { m_ctx = mg_start(&callbacks, this, web_options); mg_start_thread(websocket_keepalive_static, this); } }
web_engine::web_engine(emu_options &options) : m_options(options), m_machine(NULL), m_server(NULL), //m_lastupdatetime(0), m_exiting_core(false), m_http(m_options.http()) { if (m_http) { m_server = mg_create_server(this, ev_handler); mg_set_option(m_server, "listening_port", options.http_port()); mg_set_option(m_server, "document_root", options.http_path()); } }