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)

This commit is contained in:
Tristan B. Kildaire 2020-09-28 19:22:13 +02:00
parent 44ff9a06ad
commit 9c634c5c2e
3 changed files with 21 additions and 10 deletions

View File

@ -1,5 +1,4 @@
import std.stdio; import std.stdio;
import tristanable.manager; import tristanable.manager;
import std.socket; import std.socket;
import client; import client;
@ -194,6 +193,8 @@ void configAutoJoin(string server)
foreach(JSONValue value; config["servers"][server]["channels"].array()) foreach(JSONValue value; config["servers"][server]["channels"].array())
{ {
string channel = value.str(); string channel = value.str();
//import core.thread;
//Thread.getThis().sleep(dur!("seconds")(1));
if(dclient.join(channel)) if(dclient.join(channel))
{ {
writeln("Already present in channel "~channel); writeln("Already present in channel "~channel);

View File

@ -11,6 +11,8 @@ public class DClient
*/ */
private Manager manager; private Manager manager;
private long i = 20;
this(Address address) this(Address address)
{ {
/* Initialize the socket */ /* Initialize the socket */
@ -38,10 +40,11 @@ public class DClient
data ~= password; data ~= password;
/* Send the protocol data */ /* Send the protocol data */
manager.sendMessage(1, data); manager.sendMessage(i, data);
/* Receive the server's response */ /* Receive the server's response */
byte[] resp = manager.receiveMessage(1); byte[] resp = manager.receiveMessage(i);
i++;
return cast(bool)resp[0]; return cast(bool)resp[0];
} }
@ -56,31 +59,36 @@ public class DClient
data ~= channel; data ~= channel;
/* Send the protocol data */ /* Send the protocol data */
manager.sendMessage(1, data); manager.sendMessage(i, data);
/* Receive the server's response */ /* Receive the server's response */
byte[] resp = manager.receiveMessage(1); byte[] resp = manager.receiveMessage(i);
i++;
return cast(bool)resp[0]; return cast(bool)resp[0];
} }
public string[] list() public string[] list()
{ {
//static ulong i = 50;
string[] channels; string[] channels;
/* The protocol data to send */ /* The protocol data to send */
byte[] data = [6]; byte[] data = [6];
/* Send the protocol data */ /* Send the protocol data */
manager.sendMessage(1, data); manager.sendMessage(i, data);
/* Receive the server's response */ /* Receive the server's response */
byte[] resp = manager.receiveMessage(1); byte[] resp = manager.receiveMessage(i);
string channelList = cast(string)resp[1..resp.length]; string channelList = cast(string)resp[1..resp.length];
channels = split(channelList, ","); channels = split(channelList, ",");
/* TODO: Throw error on resp[0] zero */ /* TODO: Throw error on resp[0] zero */
i++;
return channels; return channels;
} }
@ -123,11 +131,11 @@ public class DClient
protocolData ~= cast(byte[])message; protocolData ~= cast(byte[])message;
/* Send the protocol data */ /* Send the protocol data */
manager.sendMessage(1, protocolData); manager.sendMessage(i, protocolData);
/* Receive the server's response */ /* Receive the server's response */
byte[] resp = manager.receiveMessage(1); byte[] resp = manager.receiveMessage(i);
i++;
return cast(bool)resp[0]; return cast(bool)resp[0];
} }

View File

@ -38,6 +38,8 @@ public class NotificationWatcher : Thread
} }
} }
writeln("bababbaba");
Thread.getThis().sleep(dur!("seconds")(2)); Thread.getThis().sleep(dur!("seconds")(2));
} }
} }