示例#1
0
        void OnQuery(SteamMasterServer.QueryCallback callback)
        {
            var req = GetRequest(r => r.JobID == callback.JobID);

            if (req == null)
            {
                return;
            }

            if (callback.Servers.Count == 0)
            {
                IRC.Instance.Send(req.Channel, "{0}: No servers", req.Requester.Nickname);
            }
            else if (callback.Servers.Count <= 20)
            {
                var response = string.Join(", ", callback.Servers
                                           .Take(20)
                                           .Select(s => string.Format("{0} ({1})", s.EndPoint, s.AuthedPlayers)));

                IRC.Instance.Send(req.Channel, "{0}: {1}", req.Requester.Nickname, response);
            }
            else
            {
                const int MAX_SERVERS = 5000; // the maximum amount of servers te GMS will reply with

                string response = string.Format(callback.Servers.Count == MAX_SERVERS ? ">{0}" : "{0}", callback.Servers.Count);

                IRC.Instance.Send(req.Channel, "{0}: {1} servers", req.Requester.Nickname, response);
            }
        }
示例#2
0
        void OnQuery(SteamMasterServer.QueryCallback callback)
        {
            var req = GetRequest(r => r.JobID == callback.JobID);

            if (req == null)
            {
                return;
            }

            if (callback.Servers.Count == 0)
            {
                IRC.Instance.Send(req.Channel, "{0}: Unable to find {1}: No servers in response", req.Requester.Nickname, req.SearchIP);
                return;
            }

            int index = callback.Servers.ToList().FindIndex(serv => serv.EndPoint.Address.Equals(req.SearchIP));

            if (index == -1)
            {
                IRC.Instance.Send(req.Channel, "{0}: Unable to find {1}: Not found in server response", req.Requester.Nickname, req.SearchIP);
                return;
            }

            IRC.Instance.Send(req.Channel, "{0}: Found {1} at index {2}, with {3} authed players", req.Requester.Nickname, req.SearchIP, index, callback.Servers[index].AuthedPlayers);
        }