Exemplo n.º 1
0
        private void OnReceive(IAsyncResult asyncResult)
        {
            /* UOG status received */
            try {
                int byteCount = m_Socket.EndReceive(asyncResult);
                if (byteCount == 0)
                {
                    return;
                }

                String response = new String(Encoding.ASCII.GetChars(m_Buffer, 0, byteCount - 1));

                ServerStatus status = new ServerStatus();
                foreach (string var in response.Split(','))
                {
                    string[] key_value = var.Split('=');
                    if (key_value.Length == 2)
                    {
                        string key   = key_value[0].Trim();
                        string value = key_value[1].Trim();
                        if (key == "Age")
                        {
                            status.age = Int32.Parse(value);
                        }
                        else if (key == "Clients")
                        {
                            status.clients = Int32.Parse(value);
                        }
                        else if (key == "Items")
                        {
                            status.items = Int32.Parse(value);
                        }
                        else if (key == "Chars")
                        {
                            status.chars = Int32.Parse(value);
                        }
                    }
                }

                ServerQueryTimer.SetStatus(m_Config, status);
            } catch (Exception ex) {
                log.Error(String.Format("Could not query game server {0}", m_Config.Name),
                          ex);
                ServerQueryTimer.SetStatus(m_Config, null);
            }
        }
Exemplo n.º 2
0
        public static void UOGQuery(NetState state, PacketReader pvSrc)
        {
            byte cmd = pvSrc.ReadByte();

            if (cmd != 0xFF)
            {
                return;
            }

            Console.WriteLine("Client {0} querying UOG status", state);

            string name = Core.Config.ServerName;

            if (name == null)
            {
                name = "SunUO Login";
            }

            int age     = 0;
            int clients = NetState.Instances.Count;
            int items   = 0;
            int chars   = 0;

            GameServerListConfig gsl = Core.Config.GameServerListConfig;

            if (gsl != null)
            {
                /* add values from game servers */
                foreach (GameServerConfig gs in gsl.GameServers)
                {
                    ServerStatus status = ServerQueryTimer.GetStatus(gs);
                    if (status != null)
                    {
                        age     += status.age;
                        clients += status.clients;
                        items   += status.items;
                        chars   += status.chars;
                    }
                }
            }

            string statStr = String.Format(", Name={0}, Age={1}, Clients={2}, Items={3}, Chars={4}, Mem={5}K", name, age, clients, items, chars, (int)(System.GC.GetTotalMemory(false) / 1024));

            state.Send(new UOGInfo(statStr));
            state.Dispose();
        }
Exemplo n.º 3
0
 public static void SetStatus(Config.GameServer config, ServerStatus status)
 {
     if (status == null)
         m_Status.Remove(config);
     else
         m_Status[config] = status;
 }
Exemplo n.º 4
0
        private void OnReceive(IAsyncResult asyncResult)
        {
            /* UOG status received */
            try {
                int byteCount = m_Socket.EndReceive(asyncResult);
                if (byteCount == 0)
                    return;

                String response = new String(Encoding.ASCII.GetChars(m_Buffer, 0, byteCount - 1));

                ServerStatus status = new ServerStatus();
                foreach (string var in response.Split(',')) {
                    string[] key_value = var.Split('=');
                    if (key_value.Length == 2) {
                        string key = key_value[0].Trim();
                        string value = key_value[1].Trim();
                        if (key == "Age")
                            status.age = Int32.Parse(value);
                        else if (key == "Clients")
                            status.clients = Int32.Parse(value);
                        else if (key == "Items")
                            status.items = Int32.Parse(value);
                        else if (key == "Chars")
                            status.chars = Int32.Parse(value);
                    }
                }

                ServerQueryTimer.SetStatus(m_Config, status);
            } catch (Exception ex) {
                log.Error(String.Format("Could not query game server {0}", m_Config.Name),
                          ex);
                ServerQueryTimer.SetStatus(m_Config, null);
            }
        }
Exemplo n.º 5
0
 public static void SetStatus(GameServerConfig config, ServerStatus status)
 {
     m_Status[config] = status;
 }
Exemplo n.º 6
0
 public static void SetStatus(GameServerConfig config, ServerStatus status)
 {
     m_Status[config] = status;
 }