Send order queue length in ping responses.
This commit is contained in:
@@ -128,13 +128,13 @@ namespace OpenRA.Server
|
||||
{
|
||||
// Ping packets are sent and processed internally within this thread to reduce
|
||||
// server-introduced latencies from polling loops
|
||||
if (expectLength == 9 && bytes[0] == (byte)OrderType.Ping)
|
||||
if (expectLength == 10 && bytes[0] == (byte)OrderType.Ping)
|
||||
{
|
||||
if (pingHistory.Count == MaxPingSamples)
|
||||
pingHistory.Dequeue();
|
||||
|
||||
pingHistory.Enqueue((int)(Game.RunTime - BitConverter.ToInt64(bytes, 1)));
|
||||
server.OnConnectionPing(this, pingHistory.ToArray());
|
||||
server.OnConnectionPing(this, pingHistory.ToArray(), bytes[9]);
|
||||
}
|
||||
else
|
||||
server.OnConnectionPacket(this, frame, bytes);
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace OpenRA.Server
|
||||
// - byte containing the number of sent order packets to apply
|
||||
// - 0x20: Ping
|
||||
// - Int64 containing the server timestamp when the ping was generated
|
||||
// - [client -> server only] byte containing the number of frames ready to simulate
|
||||
//
|
||||
// A connection handshake begins when a client opens a connection to the server:
|
||||
// - Server sends:
|
||||
|
||||
@@ -323,9 +323,9 @@ namespace OpenRA.Server
|
||||
events.Add(new ConnectionPacketEvent(conn, frame, data));
|
||||
}
|
||||
|
||||
internal void OnConnectionPing(Connection conn, int[] pingHistory)
|
||||
internal void OnConnectionPing(Connection conn, int[] pingHistory, byte queueLength)
|
||||
{
|
||||
events.Add(new ConnectionPingEvent(conn, pingHistory));
|
||||
events.Add(new ConnectionPingEvent(conn, pingHistory, queueLength));
|
||||
}
|
||||
|
||||
internal void OnConnectionDisconnect(Connection conn)
|
||||
@@ -1021,7 +1021,7 @@ namespace OpenRA.Server
|
||||
}
|
||||
}
|
||||
|
||||
public void ReceivePing(Connection conn, int[] pingHistory)
|
||||
public void ReceivePing(Connection conn, int[] pingHistory, byte queueLength)
|
||||
{
|
||||
// Levels set relative to the default order lag of 3 net ticks (360ms)
|
||||
// TODO: Adjust this once dynamic lag is implemented
|
||||
@@ -1367,16 +1367,18 @@ namespace OpenRA.Server
|
||||
{
|
||||
readonly Connection connection;
|
||||
readonly int[] pingHistory;
|
||||
readonly byte queueLength;
|
||||
|
||||
public ConnectionPingEvent(Connection connection, int[] pingHistory)
|
||||
public ConnectionPingEvent(Connection connection, int[] pingHistory, byte queueLength)
|
||||
{
|
||||
this.connection = connection;
|
||||
this.pingHistory = pingHistory;
|
||||
this.queueLength = queueLength;
|
||||
}
|
||||
|
||||
void IServerEvent.Invoke(Server server)
|
||||
{
|
||||
server.ReceivePing(connection, pingHistory);
|
||||
server.ReceivePing(connection, pingHistory, queueLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user