diff --git a/src/jsonapi/async-method-wrapper-template.cpp.tmpl b/src/jsonapi/async-method-wrapper-template.cpp.tmpl index 29f53ad48..324bc083f 100644 --- a/src/jsonapi/async-method-wrapper-template.cpp.tmpl +++ b/src/jsonapi/async-method-wrapper-template.cpp.tmpl @@ -58,7 +58,8 @@ $%callbackParamsSerialization%$ sStream << "data: " << compactJSON << ctx.mJson << "\n\n"; const std::string message = sStream.str(); - lService->schedule( [weakSession, message]() + auto io_context = lService->get_io_context(); + asio::post(*io_context, [weakSession, message]() { auto session = weakSession.lock(); if(!session || session->is_closed()) return; diff --git a/src/jsonapi/jsonapi-generator.py b/src/jsonapi/jsonapi-generator.py index 179546999..468ccd25a 100755 --- a/src/jsonapi/jsonapi-generator.py +++ b/src/jsonapi/jsonapi-generator.py @@ -177,7 +177,7 @@ def processFile(file): callbackParams = pType else: pType = pType.replace('&', '').replace(' ', '') - + # Apparently some xml declarations include new lines ('\n') and/or multiple spaces # Strip them using python magic pType = ' '.join(pType.split()) @@ -224,8 +224,8 @@ def processFile(file): inputParamsDeserialization = '' if hasInput: - inputParamsDeserialization += '\t\t{\n' - inputParamsDeserialization += '\t\t\tRsGenericSerializer::SerializeContext& ctx(cReq);\n' + inputParamsDeserialization += '\t\t{\n' + inputParamsDeserialization += '\t\t\tRsGenericSerializer::SerializeContext& ctx(cReq);\n' inputParamsDeserialization += '\t\t\tRsGenericSerializer::SerializeJob j(RsGenericSerializer::FROM_JSON);\n'; outputParamsSerialization = '' @@ -248,9 +248,9 @@ def processFile(file): outputParamsSerialization += '\t\t\tRS_SERIAL_PROCESS(' outputParamsSerialization += mp._name + ');\n' - if hasInput: + if hasInput: inputParamsDeserialization += '\t\t}\n' - if retvalType != 'void': + if retvalType != 'void': outputParamsSerialization += '\t\t\tRS_SERIAL_PROCESS(retval);\n' if hasOutput: outputParamsSerialization += '\t\t}\n' @@ -270,7 +270,8 @@ def processFile(file): std::chrono::seconds(maxWait+120) ); auto lService = weakService.lock(); if(!lService || lService->is_down()) return; - lService->schedule( [=]() + auto io_context = lService->get_io_context(); + asio::post(*io_context, [=]() { auto session = weakSession.lock(); if(session && session->is_open()) diff --git a/src/jsonapi/jsonapi.cpp b/src/jsonapi/jsonapi.cpp index 7cb074d47..db67db64b 100644 --- a/src/jsonapi/jsonapi.cpp +++ b/src/jsonapi/jsonapi.cpp @@ -28,6 +28,7 @@ #include #include +#include #include "jsonapi.h" @@ -403,8 +404,8 @@ JsonApiServer::JsonApiServer(): configMutex("JsonApiServer config"), return; } - lService->schedule( [weakSession, hId, event]() - { + auto io_context = lService->get_io_context(); + asio::post(*io_context, [weakSession, hId, event]() { auto session = weakSession.lock(); if(!session || session->is_closed()) { diff --git a/src/jsonapi/p3webui.cc b/src/jsonapi/p3webui.cc index b31c3a5d4..14218ba00 100644 --- a/src/jsonapi/p3webui.cc +++ b/src/jsonapi/p3webui.cc @@ -96,7 +96,10 @@ template class handler { "Content-Length", std::to_string(body.size()) } }; - session->close(restbed::OK, body, headers); + session->close(restbed::OK, restbed::Bytes( + reinterpret_cast(body.data()), + reinterpret_cast(body.data() + body.size())), + headers); } else {