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