diff --git a/Assets/Mirror/Core/NetworkConnectionToClient.cs b/Assets/Mirror/Core/NetworkConnectionToClient.cs index 361b00c34..779f289fd 100644 --- a/Assets/Mirror/Core/NetworkConnectionToClient.cs +++ b/Assets/Mirror/Core/NetworkConnectionToClient.cs @@ -125,6 +125,15 @@ protected virtual void UpdatePing() // localTime (double) instead of Time.time for accuracy over days if (NetworkTime.localTime >= lastPingTime + NetworkTime.PingInterval) { + Debug.Log($"{DateTime.Now:HH:mm:ss:fff} UpdatePing {this}"); + + if (Utils.IsHeadless()) + { + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine($"{DateTime.Now:HH:mm:ss:fff} UpdatePing {this}"); + Console.ResetColor(); + } + // TODO it would be safer for the server to store the last N // messages' timestamp and only send a message number. // This way client's can't just modify the timestamp. diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index b3ceaacd6..e7bc1735e 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -1360,7 +1360,17 @@ void OnClientSceneInternal(SceneMessage msg) } /// Called on the server when a new client connects. - public virtual void OnServerConnect(NetworkConnectionToClient conn) { } + public virtual void OnServerConnect(NetworkConnectionToClient conn) + { + Debug.Log($"{DateTime.Now:HH:mm:ss:fff} NetworkManager.OnServerConnectInternal {conn}"); + + if (Utils.IsHeadless()) + { + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine($"{DateTime.Now:HH:mm:ss:fff} NetworkManager.OnServerConnectInternal {conn}"); + Console.ResetColor(); + } + } /// Called on the server when a client disconnects. // Called by NetworkServer.OnTransportDisconnect! @@ -1492,7 +1502,10 @@ public virtual void OnStartHost() { } public virtual void OnStartServer() { } /// This is invoked when the client is started. - public virtual void OnStartClient() { } + public virtual void OnStartClient() + { + Debug.Log("OnStartClient"); + } /// This is called when a server is stopped - including when a host is stopped. public virtual void OnStopServer() { } diff --git a/Assets/Mirror/Core/NetworkTime.cs b/Assets/Mirror/Core/NetworkTime.cs index 6319970c4..e503fd8f4 100644 --- a/Assets/Mirror/Core/NetworkTime.cs +++ b/Assets/Mirror/Core/NetworkTime.cs @@ -147,6 +147,8 @@ internal static void UpdateClient() // Separate method so we can call it from NetworkClient directly. internal static void SendPing() { + Debug.Log($"SendPing"); + // send raw predicted time without the offset applied yet. // we then apply the offset to it after. NetworkPingMessage pingMessage = new NetworkPingMessage @@ -164,6 +166,15 @@ internal static void SendPing() // and time from the server internal static void OnServerPing(NetworkConnectionToClient conn, NetworkPingMessage message) { + Debug.Log($"{DateTime.Now:HH:mm:ss:fff} OnServerPing {conn}"); + + if (Utils.IsHeadless()) + { + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine($"{DateTime.Now:HH:mm:ss:fff} OnServerPing {conn}"); + Console.ResetColor(); + } + // calculate the prediction offset that the client needs to apply to unadjusted time to reach server time. // this will be sent back to client for corrections. double unadjustedError = localTime - message.localTime; @@ -191,6 +202,7 @@ internal static void OnServerPing(NetworkConnectionToClient conn, NetworkPingMes // and update time offset & prediction offset. internal static void OnClientPong(NetworkPongMessage message) { + Debug.Log("OnClientPong"); // prevent attackers from sending timestamps which are in the future if (message.localTime > localTime) return; @@ -211,7 +223,7 @@ internal static void OnClientPong(NetworkPongMessage message) // reply with a pong containing the time from the server internal static void OnClientPing(NetworkPingMessage message) { - // Debug.Log($"OnClientPing conn:{conn}"); + Debug.Log("OnClientPing"); NetworkPongMessage pongMessage = new NetworkPongMessage ( message.localTime, @@ -225,6 +237,15 @@ internal static void OnClientPing(NetworkPingMessage message) // and update time offset internal static void OnServerPong(NetworkConnectionToClient conn, NetworkPongMessage message) { + Debug.Log($"{DateTime.Now:HH:mm:ss:fff} OnServerPong {conn}"); + + if (Utils.IsHeadless()) + { + Console.ForegroundColor = ConsoleColor.Cyan; + Console.WriteLine($"{DateTime.Now:HH:mm:ss:fff} OnServerPong {conn}"); + Console.ResetColor(); + } + // prevent attackers from sending timestamps which are in the future if (message.localTime > localTime) return;