Updated sendClient and sendServer format.

This commit is contained in:
Tristan B. Kildaire 2020-05-04 13:56:18 +02:00
parent 26bbb171f7
commit b54817e418
2 changed files with 7 additions and 12 deletions

View File

@ -199,13 +199,8 @@ public final class BesterConnection : Thread
try try
{ {
/* Provide the following "data" : ..., "from" : username */
JSONValue handlerInput;
handlerInput["data"] = payloadData;
handlerInput["from"] = username;
/* Provide the handler the message and let it process it and send us a reply */ /* Provide the handler the message and let it process it and send us a reply */
HandlerResponse handlerResponse = chosenHandler.handleMessage(handlerInput); HandlerResponse handlerResponse = chosenHandler.handleMessage(payloadData);
/* TODO: Continue here, we will make all error handling do on construction as to make this all more compact */ /* TODO: Continue here, we will make all error handling do on construction as to make this all more compact */
debugPrint("<<< Message Handler [" ~ chosenHandler.getPluginName() ~ "] response >>>\n\n" ~ handlerResponse.toString()); debugPrint("<<< Message Handler [" ~ chosenHandler.getPluginName() ~ "] response >>>\n\n" ~ handlerResponse.toString());

View File

@ -167,19 +167,19 @@ public final class HandlerResponse
/* The fully response message to send back */ /* The fully response message to send back */
JSONValue clientPayload; JSONValue clientPayload;
/* Set the `handlerName` field of the header block */ // /* Set the `handlerName` field of the header block */
JSONValue handlerName; // JSONValue handlerName;
handlerName["handlerName"] = handler.getPluginName(); // handlerName["handlerName"] = handler.getPluginName();
/* Set the header of the response */ /* Set the header of the response */
JSONValue headerBlock = handlerName; JSONValue headerBlock;
clientPayload["header"] = headerBlock; clientPayload["header"] = headerBlock;
/* Set the payload of the response */ /* Set the payload of the response */
JSONValue payloadBlock; JSONValue payloadBlock;
payloadBlock["data"] = messageResponse["data"]; payloadBlock["data"] = messageResponse["data"];
payloadBlock["type"] = handler.getPluginName(); payloadBlock["type"] = handler.getPluginName();
clientPayload["data"] = payloadBlock; clientPayload["payload"] = payloadBlock;
/** /**
@ -240,7 +240,7 @@ public final class HandlerResponse
/* Set the header of the response */ /* Set the header of the response */
JSONValue headerBlock; JSONValue headerBlock;
headerBlock["handlerName"] = handler.getPluginName(); // headerBlock["handlerName"] = handler.getPluginName();
headerBlock["scope"] = "server"; headerBlock["scope"] = "server";
serverPayload["header"] = headerBlock; serverPayload["header"] = headerBlock;