Move to new branch for abstraction

This commit is contained in:
Tristan B. Kildaire 2020-04-19 16:51:04 +02:00
parent 42a9aaa210
commit 47acd4e9af
3 changed files with 27 additions and 6 deletions

View File

@ -596,6 +596,23 @@ private class BesterConnection : Thread
private bool handleResponse(JSONValue handlerResponse)
{
/* TODO: Bounds checking, type checking */
try
{
/* Get the header block */
JSONValue headerBlock = handlerResponse["header"];
/* Get the status */
ulong statusCode = headerBlock["status"].uinteger;
debugPrint("Status code: " ~ to!(string)(statusCode));
}
catch(JSONException exception)
{
debugPrint("<<< There was an error handling the response message >>>\n\n" ~ exception.toString());
return false;
}
return true;
}

View File

@ -156,14 +156,14 @@ The structure of the `[JSON message]` is as follows:
````
Allowed values for `command` are:
1. `"replyClient"`: The generated response is sent back to the
client who caused the message handler to process the original
message.
2. `"sendClients"`: The generated response must be sent to a client(s)
1. `"sendClients"`: The generated response must be sent to a client(s)
attached to the local server.
3. `"sendServers"`: The generated response must be sent to a remote
2. `"sendServers"`: The generated response must be sent to a remote
server(s).
The above two tell the server where to send the response from the
_message handler_ to. Either it can be sent
The interpretation of the entirety of the `[JSON message]` is up
to the client but the client *SHOULD* expect and interpret as
follows:

View File

@ -8,7 +8,11 @@ def runTest():
while True:
s = d.accept()[0]
print(list(s.recv(130)))
bys = json.dumps({"response" : "ppoop"})
bys = json.dumps({
"header" : {
"status" : 0,
"command" : "sendClient"
} })
print(s.send(bytes([len(bys),0,0,0])))
print(s.send(bys.encode()))