Refactored message dispatch.

This commit is contained in:
Tristan B. Kildaire 2020-05-14 00:39:45 +02:00
parent 955cc6d21d
commit fc33bd0b69
1 changed files with 5 additions and 9 deletions

View File

@ -493,19 +493,15 @@ public final class BesterConnection : Thread
connectionType = scopeField;
}
/* Attempt to get the payload block and dispatch the message */
bool dispatchStatus;
/* Get the `payload` block */
JSONValue payloadBlock = jsonMessage["payload"];
debugPrint("<<< Payload is >>>\n\n" ~ payloadBlock.toPrettyString());
/* Dispatch the message */
dispatchStatus = dispatchMessage(connectionType, payloadBlock);
/* TODO: Catch error here and not inside dispatchMessage, gets rid of the need for this if statement */
if(dispatchStatus)
/**
* Dispatch the message. If a fatal failure is
* detected then the connection will be shutdown.
*/
if(dispatchMessage(connectionType, payloadBlock))
{
debugPrint("Dispatch succeeded");
}