From 9c634c5c2ed4a78cc8034eeaab2e0e2f12c55cb9 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Mon, 28 Sep 2020 19:22:13 +0200 Subject: [PATCH] Use unique tags, Tristanable clears tags later but the point was to use unique tags also for the factor the garbage collector deletes old ones that are complete but we cannot wait for that (after receiving it is not actively removed) --- source/app.d | 3 ++- source/client.d | 26 +++++++++++++++++--------- source/notifications.d | 2 ++ 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/source/app.d b/source/app.d index 8aeae6f..5e833da 100644 --- a/source/app.d +++ b/source/app.d @@ -1,5 +1,4 @@ import std.stdio; - import tristanable.manager; import std.socket; import client; @@ -194,6 +193,8 @@ void configAutoJoin(string server) foreach(JSONValue value; config["servers"][server]["channels"].array()) { string channel = value.str(); + //import core.thread; + //Thread.getThis().sleep(dur!("seconds")(1)); if(dclient.join(channel)) { writeln("Already present in channel "~channel); diff --git a/source/client.d b/source/client.d index 3e13a3d..980e247 100644 --- a/source/client.d +++ b/source/client.d @@ -11,6 +11,8 @@ public class DClient */ private Manager manager; + + private long i = 20; this(Address address) { /* Initialize the socket */ @@ -38,10 +40,11 @@ public class DClient data ~= password; /* Send the protocol data */ - manager.sendMessage(1, data); + manager.sendMessage(i, data); /* Receive the server's response */ - byte[] resp = manager.receiveMessage(1); + byte[] resp = manager.receiveMessage(i); + i++; return cast(bool)resp[0]; } @@ -56,31 +59,36 @@ public class DClient data ~= channel; /* Send the protocol data */ - manager.sendMessage(1, data); + manager.sendMessage(i, data); /* Receive the server's response */ - byte[] resp = manager.receiveMessage(1); + byte[] resp = manager.receiveMessage(i); + i++; return cast(bool)resp[0]; } + + public string[] list() { + //static ulong i = 50; string[] channels; /* The protocol data to send */ byte[] data = [6]; /* Send the protocol data */ - manager.sendMessage(1, data); + manager.sendMessage(i, data); /* Receive the server's response */ - byte[] resp = manager.receiveMessage(1); + byte[] resp = manager.receiveMessage(i); string channelList = cast(string)resp[1..resp.length]; channels = split(channelList, ","); /* TODO: Throw error on resp[0] zero */ + i++; return channels; } @@ -123,11 +131,11 @@ public class DClient protocolData ~= cast(byte[])message; /* Send the protocol data */ - manager.sendMessage(1, protocolData); + manager.sendMessage(i, protocolData); /* Receive the server's response */ - byte[] resp = manager.receiveMessage(1); - + byte[] resp = manager.receiveMessage(i); + i++; return cast(bool)resp[0]; } diff --git a/source/notifications.d b/source/notifications.d index 2c8a7b7..86359bf 100644 --- a/source/notifications.d +++ b/source/notifications.d @@ -38,6 +38,8 @@ public class NotificationWatcher : Thread } } + writeln("bababbaba"); + Thread.getThis().sleep(dur!("seconds")(2)); } }