diff options
author | 2017-03-19 18:35:05 +0100 | |
---|---|---|
committer | 2017-03-19 18:35:05 +0100 | |
commit | ad2bedf06b7e07a3f7b382a40ff6c405a5ca6e6c (patch) | |
tree | 7d11b924aa45e383295bc175fcc81a02d11d44b8 /src/emu/machine.cpp | |
parent | f31904f2b7e5835d2a3e7a39b1dae55e6904a4aa (diff) |
Refactored HTTP handling to be easier to extend and use (nw)
Diffstat (limited to 'src/emu/machine.cpp')
-rw-r--r-- | src/emu/machine.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index bdd7ad4fc47..33868cd8d57 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -84,7 +84,6 @@ #include "network.h" #include "ui/uimain.h" #include <time.h> -#include "server_http.hpp" #include "rapidjson/include/rapidjson/writer.h" #include "rapidjson/include/rapidjson/stringbuffer.h" @@ -291,6 +290,8 @@ int running_machine::run(bool quiet) // use try/catch for deep error recovery try { + m_manager.http()->clear(); + // move to the init phase m_current_phase = MACHINE_PHASE_INIT; @@ -339,6 +340,8 @@ int running_machine::run(bool quiet) export_http_api(); + m_manager.http()->update(); + // run the CPUs until a reset or exit m_hard_reset_pending = false; while ((!m_hard_reset_pending && !m_exit_pending) || m_saveload_schedule != SLS_NONE) @@ -363,6 +366,7 @@ int running_machine::run(bool quiet) g_profiler.stop(); } + m_manager.http()->clear(); // and out via the exit phase m_current_phase = MACHINE_PHASE_EXIT; @@ -1185,9 +1189,7 @@ running_machine::logerror_callback_item::logerror_callback_item(logerror_callbac void running_machine::export_http_api() { - if (!options().http()) return; - - m_manager.http_server()->on_get("/api/machine", [this](auto response, auto request) + m_manager.http()->add("/api/machine", [this](std::string) { rapidjson::StringBuffer s; rapidjson::Writer<rapidjson::StringBuffer> writer(s); @@ -1205,8 +1207,7 @@ void running_machine::export_http_api() writer.EndArray(); writer.EndObject(); - response->type("application/json"); - response->status(200).send(s.GetString()); + return std::make_tuple(std::string(s.GetString()), 200, "application/json"); }); } |