mirror of
https://github.com/deavmi/tristanable.git
synced 2024-09-21 21:42:56 +02:00
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
This commit is contained in:
parent
e1676e2acc
commit
8942bd7f85
@ -3,6 +3,8 @@ module tristanable.manager.watcher;
|
|||||||
import core.thread : Thread;
|
import core.thread : Thread;
|
||||||
import tristanable.manager.manager : Manager;
|
import tristanable.manager.manager : Manager;
|
||||||
import std.socket;
|
import std.socket;
|
||||||
|
import bformat;
|
||||||
|
import tristanable.encoding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Watches the socket on a thread of its own,
|
* Watches the socket on a thread of its own,
|
||||||
@ -33,12 +35,25 @@ public class Watcher : Thread
|
|||||||
this.socket = socket;
|
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()
|
private void watch()
|
||||||
{
|
{
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
// TODO: Implement me
|
// 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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user