Created `sendErrorReport` function.

This commit is contained in:
Tristan B. Kildaire 2020-05-14 00:01:36 +02:00
parent 3e570e8066
commit 1d7f0b8ac2
1 changed files with 32 additions and 1 deletions

View File

@ -264,6 +264,7 @@ public final class BesterConnection : Thread
debugPrint("Handler section done (for client)");
/* TODO: Handle response */
}
/* If no message handler for the specified type could be found */
else
{
/* TODO: Implement error handling */
@ -272,12 +273,42 @@ public final class BesterConnection : Thread
/* Send error message to client */
JSONValue handlerName = payloadType;
sendStatus(1, handlerName);
dispatchStatus = false;
}
return dispatchStatus;
}
/* Send an error report */
public void sendErrorReport(string id)
{
/* Construct the response */
JSONValue statusMessage;
/* Construct the haeder block */
JSONValue headerBlock;
headerBlock["status"] = "bad";
/* Attach the header block */
statusMessage["header"] = headerBlock;
/* Create the payload block */
JSONValue payloadBlock;
payloadBlock["id"] = id;
/* Attach the payload block */
statusMessage["payload"] = payloadBlock;
try
{
/* Send the message */
sendMessage(clientConnection, statusMessage);
}
catch(NetworkException e)
{
debugPrint("Error sending status message");
}
}
/* Send a status message to the client */
public void sendStatus(uint code, JSONValue data)
{