public static bool TryTerminateRemoteServer(UdpPingClient client)
        {
            if (client == null)
                return false;

            client.ShutdownRemoteServer();
            client.Dispose();

            return true;
        }
 public void Dispose()
 {
     if (m_PingClient != null)
     {
         m_PingClient.Dispose();
         m_PingClient = null;
         m_Stats?.StopMeasuring();
         m_Stats = null;
     }
 }
        public void Start(string endpoint)
        {
            if (m_PingClient != null)
                throw new InvalidOperationException($"{nameof(Start)} cannot be called after pinging has already started");

            if (!NetworkUtils.TryParseEndpoint(endpoint, out var serverEndPoint))
                throw new ArgumentException("Could not parse endpoint");

            m_PingClient = new UdpPingClient(serverEndPoint);
            m_Stats = m_PingClient.Stats;
        }
        // Try to terminate the current server, then clean up the instance
        public bool TryTerminateRemoteServer(bool dispose = false)
        {
            if (TryTerminateRemoteServer(m_PingClient))
            {
                m_PingClient = null;

                if (dispose)
                    Dispose();

                return true;
            }

            return false;
        }
        public static bool TryGetNewPingClient(string endpoint, out UdpPingClient newClient)
        {
            newClient = null;

            if (!NetworkUtils.TryParseEndpoint(endpoint, out var serverEndPoint))
            {
                Debug.LogError("Could not parse endpoint");
                return false;
            }

            try
            {
                newClient = new UdpPingClient(serverEndPoint);
                return true;
            }
            catch (Exception e)
            {
                Debug.LogError($"Could not create new {nameof(UdpPingClient)}: {e.Message}");
                return false;
            }
        }