mirror of
https://github.com/deavmi/birchwood
synced 2024-09-20 10:23:31 +02:00
ConnectionInfo
- Set default `fakeLag` to `1` - Added `getFakeLag()` and `setFakeLag()` Client - Added `getConnInfo()` to return the client's associated `ConnectionInfo` Sender - Use the fakelag configured by user
This commit is contained in:
parent
044625194d
commit
44cce182ae
@ -71,6 +71,10 @@ public class Client : Thread
|
||||
//TODO: Do something here, tare downs
|
||||
}
|
||||
|
||||
public ConnectionInfo getConnInfo()
|
||||
{
|
||||
return connInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -875,6 +879,11 @@ public class Client : Thread
|
||||
//snootnet: 178.62.125.123
|
||||
//bonobonet: fd08:8441:e254::5
|
||||
ConnectionInfo connInfo = ConnectionInfo.newConnection("worcester.community.networks.deavmi.assigned.network", 6667, "testBirchwood");
|
||||
|
||||
// // Set the fakelag to 1 second
|
||||
// connInfo.setFakeLag(1);
|
||||
|
||||
// Create a new Client
|
||||
Client client = new Client(connInfo);
|
||||
|
||||
client.connect();
|
||||
|
@ -79,9 +79,6 @@ public final class SenderThread : Thread
|
||||
*/
|
||||
private void sendHandlerFunc()
|
||||
{
|
||||
/* TODO: Hoist up into ConnInfo */
|
||||
ulong fakeLagInBetween = 1;
|
||||
|
||||
while(client.running)
|
||||
{
|
||||
// // Do a once-off call to `ensure()` here which then only runs once and
|
||||
@ -115,7 +112,7 @@ public final class SenderThread : Thread
|
||||
foreach(ubyte[] message; sendQueue[])
|
||||
{
|
||||
client.socket.send(message);
|
||||
Thread.sleep(dur!("seconds")(fakeLagInBetween));
|
||||
Thread.sleep(dur!("seconds")(client.getConnInfo().getFakeLag()));
|
||||
}
|
||||
|
||||
/* Empty the send queue */
|
||||
|
@ -14,7 +14,7 @@ public struct ConnectionInfo
|
||||
private ulong bulkReadSize;
|
||||
|
||||
/* Client behaviour (TODO: what is sleep(0), like nothing) */
|
||||
private ulong fakeLag = 0;
|
||||
private ulong fakeLag;
|
||||
|
||||
/* The quit message */
|
||||
public const string quitMessage;
|
||||
@ -26,6 +26,9 @@ public struct ConnectionInfo
|
||||
this.nickname = nickname;
|
||||
this.bulkReadSize = bulkReadSize;
|
||||
this.quitMessage = quitMessage;
|
||||
|
||||
// Set the default fakelag to 1
|
||||
this.fakeLag = 1;
|
||||
}
|
||||
|
||||
public ulong getBulkReadSize()
|
||||
@ -38,6 +41,16 @@ public struct ConnectionInfo
|
||||
return addrInfo;
|
||||
}
|
||||
|
||||
public ulong getFakeLag()
|
||||
{
|
||||
return fakeLag;
|
||||
}
|
||||
|
||||
public void setFakeLag(ulong fakeLag)
|
||||
{
|
||||
this.fakeLag = fakeLag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ConnectionInfo struct representing a client configuration which
|
||||
* can be provided to the Client class to create a new connection based on its
|
||||
|
Loading…
Reference in New Issue
Block a user