mirror of
https://github.com/deavmi/birchwood
synced 2024-09-20 14:03:05 +02:00
Merge branch 'master' into ircv3
This commit is contained in:
commit
8d1fbbdece
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user