1
0
Fork 0
mirror of https://github.com/besterprotocol/besterd synced 2023-12-13 21:00:32 +01:00

Added print out of response and made test handler send one

This commit is contained in:
Tristan B. Kildaire 2020-04-19 15:34:38 +02:00
parent d18cf4ae4f
commit 3b40aa5197
2 changed files with 11 additions and 5 deletions

View file

@ -441,7 +441,7 @@ private class BesterConnection : Thread
}
private bool handlerRun(MessageHandler chosenHandler, JSONValue payload)
private JSONValue handlerRun(MessageHandler chosenHandler, JSONValue payload)
{
/* TODO: Send and receive data here */
@ -591,7 +591,7 @@ private class BesterConnection : Thread
/* TODO: Set dispatchStatus */
return true;
return parseJSON(cast(string)fullMessage);
}
/* TODO: Version 2 of message dispatcher */
@ -625,7 +625,11 @@ private class BesterConnection : Thread
debugPrint("Chosen handler for payload type \"" ~ payloadType ~ "\" is " ~ chosenHandler.getPluginName());
/* TODO: Collect return value */
handlerRun(chosenHandler, payloadData);
JSONValue response = handlerRun(chosenHandler, payloadData);
debugPrint("<<< Message Handler [" ~ chosenHandler.getPluginName() ~ "] response >>>\n\n" ~ response.toPrettyString());
/* TODO: Handle response */
}
else
{

View file

@ -1,5 +1,5 @@
import socket
import json
def runTest():
d=socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@ -8,7 +8,9 @@ def runTest():
while True:
s = d.accept()[0]
print(list(s.recv(130)))
print(s.send(bytes([4,0,0,0,65,66,66,65])))
bys = json.dumps({"response" : "ppoop"})
print(s.send(bytes([len(bys),0,0,0])))
print(s.send(bys.encode()))
while True: pass