Took a good 2 hours to change all the messages into JSON format and make it work.
But it is done. All is JSON.
Using it like a map, currently with three key-value pairs:
"id" : for entering a session ID of another session if needed. Currently used for the web client to receive a acknowledge response to confirm that the target received the message (mainly for testing purposes).
"type" : probably the most functional data going through all this. Current types are
STARTUP_TYPE - for when the target sends its initial message, the server uses this to mark which session is the target.
REQUEST_TYPE - for when the web client sends a request to the target. Server uses this to send request to target.
ACK_TYPE - for when the target finishes carrying out the requests and sends an acknowledgement of the completion of the request to the server. Server uses this to send confirmation to the web client
MISC_MSG_TYPE - for anything else.
DEBUG_TYPE - currently for the pinging that the Raspberry Pi is sending to the server.
"message" : currently holds messages that are visible in the web client's screen. As the screen would most likely be gone in the end, this and MISC_MSG_TYPE might disappear.
Anyways, code got cleaner once every message was converted to JSON (no more regex blobs), but it's still messy in some parts.
Comments
Post a Comment