From b195cc062a09fed8326813f5e72270d506045cd5 Mon Sep 17 00:00:00 2001 From: JesusLuvsYooh <57072365+JesusLuvsYooh@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:56:31 +0000 Subject: [PATCH] fix: Port log for when Server has started and is listening. (#3642) Allows users to know if Server has actually started and which port, and not just initialised. Credits to Gadget for code and suggesting to have it in NetworkServer. (Originally was going in KCP-only) --- Assets/Mirror/Core/NetworkServer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Assets/Mirror/Core/NetworkServer.cs b/Assets/Mirror/Core/NetworkServer.cs index 76b9c4fd4..876cbb516 100644 --- a/Assets/Mirror/Core/NetworkServer.cs +++ b/Assets/Mirror/Core/NetworkServer.cs @@ -122,6 +122,17 @@ public static void Listen(int maxConns) active = true; RegisterMessageHandlers(); + + if (Transport.active is PortTransport portTransport) + { +#if UNITY_SERVER + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine($"Server listening on port {portTransport.Port}"); + Console.ResetColor(); +#else + Debug.Log($"Server listening on port {portTransport.Port}"); +#endif + } } // initialization / shutdown ///////////////////////////////////////////