diff --git a/dub.json b/dub.json index a2f3e25..f77c423 100644 --- a/dub.json +++ b/dub.json @@ -7,7 +7,7 @@ "dependencies": { "dlog": "0.3.19", "eventy": "0.4.0", - "libsnooze": "0.3.3" + "libsnooze": "1.0.0-beta" }, "description": "A sane IRC framework for the D language", "license": "LGPL-3.0", diff --git a/source/birchwood/client/receiver.d b/source/birchwood/client/receiver.d index f4f8e9e..43600a5 100644 --- a/source/birchwood/client/receiver.d +++ b/source/birchwood/client/receiver.d @@ -20,6 +20,11 @@ import std.string : indexOf; import birchwood.client.events : PongEvent, IRCEvent; import std.string : cmp; +version(unittest) +{ + import std.stdio : writeln; +} + /** * Manages the receive queue and performs * message parsing and event triggering @@ -126,9 +131,28 @@ public final class ReceiverThread : Thread // TODO: See above notes about libsnooze behaviour due // ... to usage in our context - - // TODO: Catch InterruptedException here - receiveEvent.wait(); // TODO: Catch any exceptions from libsnooze + try + { + receiveEvent.wait(); + } + catch(InterruptedException e) + { + version(unittest) + { + writeln("wait() interrupted"); + } + continue; + } + catch(SnoozeError e) + { + // TODO: This should crash and end + version(unittest) + { + writeln("wait() had an error"); + } + continue; + } + diff --git a/source/birchwood/client/sender.d b/source/birchwood/client/sender.d index 0e7f121..4d4b632 100644 --- a/source/birchwood/client/sender.d +++ b/source/birchwood/client/sender.d @@ -14,6 +14,11 @@ import libsnooze; import birchwood.client; +version(unittest) +{ + import std.stdio : writeln; +} + /** * Manages the send queue */ @@ -116,9 +121,30 @@ public final class SenderThread : Thread // TODO: See above notes about libsnooze behaviour due // ... to usage in our context + try + { + sendEvent.wait(); + } + catch(InterruptedException e) + { + version(unittest) + { + writeln("wait() interrupted"); + } + continue; + } + catch(SnoozeError e) + { + // TODO: This should crash and end + version(unittest) + { + writeln("wait() had an error"); + } + continue; + } + + - // TODO: Catch InterruptedException here - sendEvent.wait(); // TODO: Catch any exceptions from libsnooze // TODO: After the above call have a once-off call to `ensure()` here // ... which then only runs once and sets a `ready` flag for the Client