Skip to main content

ServerDiagnosticsManager

A class in Root.Township, the global namespace.

Server: while the server runs, sends its FPS to players who asked for it and logs profiling data on an interval. Marked obsolete in favour of the new analytics system.

Constructors​

MemberWhat it is
ServerDiagnosticsManager()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
static Dictionary<IPlayer, bool> PlayersToSendToPer player, whether they get server FPS messages. Players are added as false the first time they're seen.
static readonly ConsoleEvent<ServerProfilingData> ServerProfileConsole event (ProfilingData) that receives the profiling data.
6 private and internal fields
MemberWhat it is
private AltaCoroutine autoProfileHandle for the auto profile coroutine. Not used.
private ServerProfilingData diagnosticsThe profiling data being collected.
private bool isSendingInspector Test Send button that calls SendDiagnosticsToDatabase.
private static readonly Logger loggerNLog logger for this class.
private AltaCoroutine sendFpsToClientsCoroutineThe running FPS send coroutine.
private AltaCoroutine sendToDBCoroutineThe running diagnostics coroutine.

Properties​

MemberWhat it is
static bool IsActive { get; set; }True while the diagnostics coroutines are running.

Methods​

9 private and internal methods
MemberWhat it is
private IEnumerator AutoProfile() (iterator)Coroutine that takes a profile sample when FPS drops below 60, then waits 15 minutes. Never started in this code.
private void OnDestroy()Stops the coroutines.
private void SendDiagnosticsToDatabase()Caches the profiling data, logs it, fires the ServerProfile console event and resets the data.
private IEnumerator SendDiagnosticsToDatabaseCoroutine() (iterator)Coroutine that calls SendDiagnosticsToDatabase every DiagnosticsSendInterval seconds while the server exists.
private void SendServerFpsToAllClients()Sends a ServerDiagnostics message to each player flagged true in PlayersToSendTo.
private IEnumerator SendServerFpsToClients() (iterator)Coroutine that sends the server FPS every FpsSendInterval seconds while the server exists.
private void Start()Hooks server start and end so the coroutines start and stop with the server.
private void StartUpdatingAndSending()Creates the profiling data, inits the network profiler and starts both coroutines.
private void StopUpdatingAndSending()Stops both coroutines and clears IsActive.