From 9b750783527ab7f6daedf410c25832171ffecb9d Mon Sep 17 00:00:00 2001 From: James Wood Date: Mon, 24 Apr 2017 13:41:22 +0100 Subject: [PATCH] Add debug log for latency on server --- Assets/scripts/utils/TableNetworking.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Assets/scripts/utils/TableNetworking.cs b/Assets/scripts/utils/TableNetworking.cs index 61fff75..c25c823 100644 --- a/Assets/scripts/utils/TableNetworking.cs +++ b/Assets/scripts/utils/TableNetworking.cs @@ -14,12 +14,29 @@ public class TableNetworking : NetworkBehaviour [SyncVar] public bool selected; + public float logPingFrequency = 5.0f; + [ServerCallback] void Start () { selected = false; table = ""; variant = ""; + + InvokeRepeating("LogPing", 0.0f, logPingFrequency); + } + + void OnClientConnect(NetworkConnection conn) + { + InvokeRepeating("LogPing", 0.0f, logPingFrequency); + } + + void LogPing() + { + foreach (NetworkClient conn in NetworkClient.allClients) + { + Debug.Log("Ping for connection " + conn.connection.address.ToString() + ": " + conn.GetRTT().ToString() + " (ms)"); + } } public string GetTable()