Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/jsonapi/async-method-wrapper-template.cpp.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 7 additions & 6 deletions src/jsonapi/jsonapi-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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 = ''
Expand All @@ -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'
Expand All @@ -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())
Expand Down
5 changes: 3 additions & 2 deletions src/jsonapi/jsonapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <restbed>
#include <openssl/crypto.h>
#include <asio.hpp>


#include "jsonapi.h"
Expand Down Expand Up @@ -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())
{
Expand Down
5 changes: 4 additions & 1 deletion src/jsonapi/p3webui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ template<MimeTypeIndex MIME_TYPE_INDEX> class handler
{ "Content-Length", std::to_string(body.size()) }
};

session->close(restbed::OK, body, headers);
session->close(restbed::OK, restbed::Bytes(
reinterpret_cast<const std::byte*>(body.data()),
reinterpret_cast<const std::byte*>(body.data() + body.size())),
headers);
}
else
{
Expand Down
Loading