From 8942bd7f85730018ff0fce23c76039f824dc0ca1 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 27 Mar 2023 21:58:04 +0200 Subject: [PATCH] Watcher - Added import for `bformat` and `encoding` module - Documented `watch()` - Added `bformat` read-and-decode `receiveMessage(Socket, ref byte[])` call followed by a `TaggedMessage.decode(byte[])` call --- source/tristanable/manager/watcher.d | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/source/tristanable/manager/watcher.d b/source/tristanable/manager/watcher.d index 2fd841f..ef28e49 100644 --- a/source/tristanable/manager/watcher.d +++ b/source/tristanable/manager/watcher.d @@ -3,6 +3,8 @@ module tristanable.manager.watcher; import core.thread : Thread; import tristanable.manager.manager : Manager; import std.socket; +import bformat; +import tristanable.encoding; /** * Watches the socket on a thread of its own, @@ -33,12 +35,25 @@ public class Watcher : Thread this.socket = socket; } - + /** + * Watches the socket for incoming messages + * and decodes them on the fly, placing + * the final message in the respective queue + */ private void watch() { while(true) { // TODO: Implement me + + /* Do a bformat read-and-decode */ + byte[] wireTristan; + receiveMessage(socket, wireTristan); + + /* Decode the received bytes into a tagged message */ + TaggedMessage decodedMessage = TaggedMessage.decode(wireTristan); + + } } } \ No newline at end of file