Exemple #1
0
    /// <summary>
    /// Returns a list of responsive server's server info when finished
    /// </summary>
    /// <returns></returns>
    public async System.Threading.Tasks.Task <System.Collections.Generic.List <Steamworks.Data.ServerInfo> > ResponsiveServers()
    {
        var responsive = new System.Collections.Generic.List <Steamworks.Data.ServerInfo>();


        using (var list = new Steamworks.ServerList.LocalNetwork())
        {
            await list.RunQueryAsync();

            foreach (var server in list.Responsive)
            {
                responsive.Add(server);
            }
        }


        using (var list = new Steamworks.ServerList.Internet())
        {
            await list.RunQueryAsync();

            foreach (var server in list.Responsive)
            {
                responsive.Add(server);
            }
        }


        return(responsive);
    }
        public async Task ServerListInternet()
        {
            using (var list = new ServerList.Internet())
            {
                var success = await list.RunQueryAsync();

                Console.WriteLine($"success {success}");
                Console.WriteLine($"Found {list.Responsive.Count} Responsive Servers");
                Console.WriteLine($"Found {list.Unresponsive.Count} Unresponsive Servers");
            }
        }
        public async Task FilterByMap()
        {
            using (var list = new ServerList.Internet())
            {
                list.AddFilter("map", "de_dust");

                var success = await list.RunQueryAsync();

                Console.WriteLine($"success {success}");
                Console.WriteLine($"Found {list.Responsive.Count} Responsive Servers");
                Console.WriteLine($"Found {list.Unresponsive.Count} Unresponsive Servers");

                foreach (var server in list.Responsive)
                {
                    Assert.AreEqual(server.Map.ToLower(), "de_dust");

                    Console.WriteLine($"[{server.Map}] - {server.Name}");
                }
            }
        }
        public async Task ServerListInternetInterupted()
        {
            using (var list = new ServerList.Internet())
            {
                var task = list.RunQueryAsync();

                await Task.Delay(1000);

                Console.WriteLine($"Querying..");

                list.Cancel();

                foreach (var s in list.Responsive)
                {
                    Console.WriteLine($"{s.Address} {s.Name}");
                }

                Console.WriteLine($"Found {list.Responsive.Count} Responsive Servers");
                Console.WriteLine($"Found {list.Unresponsive.Count} Unresponsive Servers");
                Console.WriteLine($"task.IsCompleted {task.IsCompleted}");
            }
        }
Exemple #5
0
        public async Task SourceQuery()
        {
            using (var list = new ServerList.Internet())
            {
                var task = list.RunQueryAsync();
                await Task.Delay(1000);

                list.Cancel();

                foreach (var s in list.Responsive.Take(10).ToArray())
                {
                    Console.WriteLine($"{s.Name} [{s.Address}]");

                    var rules = await s.QueryRulesAsync();

                    Assert.IsNotNull(rules);

                    foreach (var rule in rules)
                    {
                        Console.WriteLine($"	{rule.Key}  = {rule.Value}");
                    }
                }
            }
        }
Exemple #6
0
    // Updates server list when refreshServerList is set to true through inspector
    private async void Update()
    {
        if (initClient)
        {
            InitClient();
            initClient = false;
        }


        if (debugIP)
        {
            Debug.Log(SteamServer.PublicIp);
            debugIP = false;
        }


        if (refreshServerList)
        {
            using (var list = new Steamworks.ServerList.Internet())
            {
                // list.AddFilter("map", "de_dust");
                await list.RunQueryAsync();

                foreach (var server in list.Responsive)
                {
                    Debug.Log($"{server.Address} {server.Name}");
                }

                Debug.Log("Found " + list.Responsive.Count + " internet servers.");
            }

            refreshServerList = false;
        }


    }