diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index eda9dcd..a363620 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -26,12 +26,16 @@ __gshared static this() // TODO: Make abstract and for unit tests make a `DefaultClient` // ... which logs outputs for the `onX()` handler functions + +/** + * IRC client + */ public class Client : Thread { /** * Connection information */ - private ConnectionInfo connInfo; + package shared ConnectionInfo connInfo; /* TODO: We should learn some info in here (or do we put it in connInfo)? */ private string serverName; //TODO: Make use of @@ -42,9 +46,13 @@ public class Client : Thread package Socket socket; /** - * Receive queue and send queue managers + * Receive queue meneger */ private ReceiverThread receiver; + + /** + * Send queue manager + */ private SenderThread sender; /** @@ -54,6 +62,14 @@ public class Client : Thread package bool running = false; + + /** + * Constructs a new IRC client with the given configuration + * info + * + * Params: + * connInfo = the connection parameters + */ this(ConnectionInfo connInfo) { super(&loop); @@ -66,12 +82,20 @@ public class Client : Thread this.sender = new SenderThread(this); } + /** + * TODO: ANything worth callin on destruction? + */ ~this() { //TODO: Do something here, tare downs } - // TODO: Investigate + /** + * Retrieve the active configuration at this + * moment + * + * Returns: the ConnectionInfo struct + */ public ConnectionInfo getConnInfo() { return connInfo; diff --git a/source/birchwood/client/sender.d b/source/birchwood/client/sender.d index 5d7fbc0..c51c423 100644 --- a/source/birchwood/client/sender.d +++ b/source/birchwood/client/sender.d @@ -129,7 +129,7 @@ public final class SenderThread : Thread foreach(ubyte[] message; sendQueue[]) { client.socket.send(message); - Thread.sleep(dur!("seconds")(client.getConnInfo().getFakeLag())); + Thread.sleep(dur!("seconds")(client.connInfo.getFakeLag())); } /* Empty the send queue */ diff --git a/source/birchwood/config/conninfo.d b/source/birchwood/config/conninfo.d index 5181e8f..c9d01f0 100644 --- a/source/birchwood/config/conninfo.d +++ b/source/birchwood/config/conninfo.d @@ -10,7 +10,7 @@ import birchwood.client.exceptions; * Represents the connection details for a server * to connect to */ -public struct ConnectionInfo +public shared struct ConnectionInfo { /** * Server address @@ -54,7 +54,8 @@ public struct ConnectionInfo */ private this(Address addrInfo, string nickname, ulong bulkReadSize = 20, string quitMessage = "birchwood client disconnecting...") { - this.addrInfo = addrInfo; + // NOTE: Not sure if much mutable in Address anyways + this.addrInfo = cast(shared Address)addrInfo; this.nickname = nickname; this.bulkReadSize = bulkReadSize; this.quitMessage = quitMessage; @@ -73,6 +74,17 @@ public struct ConnectionInfo return this.bulkReadSize; } + /** + * Sets the read-dequeue size + * + * Params: + * bytes = the number of bytes to dequeue at a time + */ + public void setBulkReadSize(ulong bytes) + { + this.bulkReadSize = bytes; + } + /** * Get the address of the endpoint server * @@ -80,7 +92,7 @@ public struct ConnectionInfo */ public Address getAddr() { - return addrInfo; + return cast(Address)addrInfo; } /**