fix(NetworkManager): CalculateConnectionQuality and OnConnectionQualityChanged are now public

- Also moved them down with the rest of the OnClient overrides
- Also rewrote the comments as <summary> comments
This commit is contained in:
MrGadget1024 2023-11-04 17:49:04 -04:00
parent 1cda80369a
commit c66f40f925

View File

@ -268,21 +268,6 @@ void UpdateConnectionQuality()
}
}
// users can overwrite this to run their own connection quality estimation.
protected virtual void CalculateConnectionQuality()
{
// NetworkClient.connectionQuality = ConnectionQualityHeuristics.Pragmatic(NetworkClient.initialBufferTime, NetworkClient.bufferTime);
NetworkClient.connectionQuality = ConnectionQualityHeuristics.Simple(NetworkTime.rtt, NetworkTime.rttVariance);
}
// users can overwrite this to display connection quality warnings, etc.
protected virtual void OnConnectionQualityChanged(ConnectionQuality previous, ConnectionQuality current)
{
// logging the change is very useful to track down user's lag reports.
// we want to include as much detail as possible for debugging.
Debug.Log($"[Mirror] Connection Quality changed from {previous} to {current}:\n rtt={(NetworkTime.rtt*1000):F1}ms\n rttVar={(NetworkTime.rttVariance*1000):F1}ms\n bufferTime={(NetworkClient.bufferTime*1000):F1}ms");
}
////////////////////////////////////////////////////////////////////////
// keep the online scene change check in a separate function.
@ -1400,6 +1385,21 @@ public virtual void OnClientConnect()
/// <summary>Called on clients when disconnected from a server.</summary>
public virtual void OnClientDisconnect() { }
/// <summary>Called on client when connection quality is calculated. Override to use your own measurements.</summary>
public virtual void CalculateConnectionQuality()
{
// NetworkClient.connectionQuality = ConnectionQualityHeuristics.Pragmatic(NetworkClient.initialBufferTime, NetworkClient.bufferTime);
NetworkClient.connectionQuality = ConnectionQualityHeuristics.Simple(NetworkTime.rtt, NetworkTime.rttVariance);
}
/// <summary>Called on client when connection quality changes. Override to show your own warnings or UI visuals.</summary>
public virtual void OnConnectionQualityChanged(ConnectionQuality previous, ConnectionQuality current)
{
// logging the change is very useful to track down user's lag reports.
// we want to include as much detail as possible for debugging.
Debug.Log($"[Mirror] Connection Quality changed from {previous} to {current}:\n rtt={(NetworkTime.rtt * 1000):F1}ms\n rttVar={(NetworkTime.rttVariance * 1000):F1}ms\n bufferTime={(NetworkClient.bufferTime * 1000):F1}ms");
}
/// <summary>Called on client when transport raises an exception.</summary>
public virtual void OnClientError(TransportError error, string reason) { }