Esempio n. 1
0
        public void GetServer(string ip, int port, string friendlyName)
        {
            FriendlyName = friendlyName;
            var ssql = new SSQL();

            try
            {
                var info = ssql.Server(new IPEndPoint(IPAddress.Parse(ip), port));
                PlayerCount = Convert.ToInt32(info.PlayerCount);
                MaxPlayers  = Convert.ToInt32(info.MaxPlayers);
                ServerName  = info.Name;
                Map         = info.Map;
                Game        = info.Game;

                IP   = ip;
                Port = port;

                Offline = false;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Offline = true;
            }
        }
Esempio n. 2
0
        public static double GetServerVersion(string host, int port)
        {
            try
            {
                IPAddress  ip     = Dns.GetHostAddresses(host).First(i => i.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
                ServerInfo server = Ssql.Server(new IPEndPoint(ip, port));
                Match      match  = ServerName.Match(server.Name);
                if (match.Success)
                {
                    double version = double.Parse(match.Groups["Version"].ToString(), CultureInfo.InvariantCulture);
                    return(version);
                }
            }
            catch (Exception ex)
            {
                // Server down
            }

            return(0);
        }