Exemplo n.º 1
0
        public void Update()
        {
            try
            {
                QueryClient      client     = new QueryClient();
                PacketCollection packets    = client.QueryServer(this.Settings);
                string           dataString = packets.GetDataString();
#if DEBUG
                Logger.Log(packets);
                Logger.LogData(packets);
                Logger.LogData(dataString);
#endif

                string[] data = Regex.Split(
                    dataString,
                    Encoding.ASCII.GetString(new byte[] { 00, 00, 01 }),
                    RegexOptions.Compiled);

                this.ServerInfo = ServerInfo.Parse(data[0]);
                this.Players    = PlayerCollection.Parse(data[1]);
                ChangeOnlineState(true);
            }
            catch (SocketException ex)
            {
                ChangeOnlineState(false);
                Trace.WriteLine(
                    String.Format(CultureInfo.InvariantCulture, "{0}", ex.Message),
                    "Network Error");
            }
            catch (Exception ex)
            {
                Trace.WriteLine(
                    String.Format(CultureInfo.InvariantCulture, "{0}", ex.Message), "General");
#if DEBUG
                Trace.WriteLine(ex.StackTrace, "Error");
#endif
            }
        }
Exemplo n.º 2
0
        public void Update()
        {
            try
            {
                QueryClient client = new QueryClient();
                PacketCollection packets = client.QueryServer(this.Settings);
                string dataString = packets.GetDataString();
            #if DEBUG
                Logger.Log(packets);
                Logger.LogData(packets);
                Logger.LogData(dataString);
            #endif

                string[] data = Regex.Split(
                    dataString,
                    Encoding.ASCII.GetString(new byte[] { 00, 00, 01 }),
                    RegexOptions.Compiled);

                this.ServerInfo = ServerInfo.Parse(data[0]);
                this.Players = PlayerCollection.Parse(data[1]);
                ChangeOnlineState(true);
            }
            catch (SocketException ex)
            {
                ChangeOnlineState(false);
                Trace.WriteLine(
                    String.Format(CultureInfo.InvariantCulture, "{0}", ex.Message),
                    "Network Error");
            }
            catch (Exception ex)
            {
                Trace.WriteLine(
                    String.Format(CultureInfo.InvariantCulture, "{0}", ex.Message), "General");
            #if DEBUG
                Trace.WriteLine(ex.StackTrace, "Error");
            #endif
            }
        }