Exemple #1
0
    /// <summary>
    /// Refresh the lobby list asynchronously
    /// </summary>
    private async Task RefreshLobbyList()
    {
        var query = new Steamworks.Data.LobbyQuery();

        Steamworks.Data.Lobby[] lobbylist = await query.RequestAsync();

        if (lobbylist != null)
        {
            if (lobbylist.Length > 0)
            {
                for (int i = 0; i < lobbylist.Length; i++)
                {
                    bool haveThisServer = false;
                    for (int j = 0; j < serverList.Count; j++)
                    {
                        var data = serverList[j];
                        if (data.lobby.Id == lobbylist[i].Id)
                        {
                            haveThisServer = true;
                            UpdateItem(data);
                            continue;
                        }
                    }

                    if (haveThisServer)
                    {
                        continue;
                    }

                    AddServer(lobbylist[i]);
                }
            }
        }
    }
    private async Task RefreshLobbies()
    {
        var lobbyQuery = new Steamworks.Data.LobbyQuery();
        var lobbyList  = await lobbyQuery.RequestAsync();

        if (lobbyList == null)
        {
            BMSLog.Log("Lobbylist is null!");
            return;
        }

        var serversToKeep = new HashSet <Steamworks.Data.Lobby>();

        foreach (var lobby in lobbyList)
        {
            if (lobby.GetData("FNR-FP") == "blob")
            {
                AddServer(lobby);
                serversToKeep.Add(lobby);
            }
        }

        var serversToRemove = new HashSet <FacepunchServerListItemData>();

        foreach (var entry in serverList)
        {
            if (!serversToKeep.Contains(entry.lobby))
            {
                serversToRemove.Add(entry);
            }
        }

        foreach (var entry in serversToRemove)
        {
            RemoveServer(entry);
        }
    }