The ping/pong orders are replaced with a dedicated (and much smaller) Ping packet that is handled directly in the client and server Connection wrappers. This allows clients to respond when the orders are processed, instead of queuing the pong order to be sent in the next frame (which added an extra 120ms of unwanted latency). The ping frequency has been raised to 1Hz, and pings are now routed through the server events queue in preparation for the future dynamic latency system. The raw ping numbers are no longer sent to clients, the server instead evaluates a single ConnectionQuality value that in the future may be based on more than just the ping times.
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
#region Copyright & License Information
|
|
/*
|
|
* Copyright 2007-2021 The OpenRA Developers (see AUTHORS)
|
|
* This file is part of OpenRA, which is free software. It is made
|
|
* available to you under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation, either version 3 of
|
|
* the License, or (at your option) any later version. For more
|
|
* information, see COPYING.
|
|
*/
|
|
#endregion
|
|
|
|
using OpenRA.Network;
|
|
using OpenRA.Widgets;
|
|
|
|
namespace OpenRA.Mods.Common.Widgets.Logic
|
|
{
|
|
public class LatencyTooltipLogic : ChromeLogic
|
|
{
|
|
[ObjectCreator.UseCtor]
|
|
public LatencyTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, OrderManager orderManager, Session.Client client)
|
|
{
|
|
var latencyPrefix = widget.Get<LabelWidget>("LATENCY_PREFIX");
|
|
var latencyPrefixFont = Game.Renderer.Fonts[latencyPrefix.Font];
|
|
var latency = widget.Get<LabelWidget>("LATENCY");
|
|
var latencyFont = Game.Renderer.Fonts[latency.Font];
|
|
var rightMargin = widget.Bounds.Width;
|
|
|
|
latency.Bounds.X = latencyPrefix.Bounds.X + latencyPrefixFont.Measure(latencyPrefix.Text + " ").X;
|
|
|
|
widget.IsVisible = () => client != null;
|
|
tooltipContainer.BeforeRender = () =>
|
|
{
|
|
if (widget.IsVisible())
|
|
widget.Bounds.Width = latency.Bounds.X + latencyFont.Measure(latency.GetText()).X + rightMargin;
|
|
};
|
|
|
|
latency.GetText = () => LobbyUtils.LatencyDescription(client);
|
|
latency.GetColor = () => LobbyUtils.LatencyColor(client);
|
|
}
|
|
}
|
|
}
|