void OnLobbyDataUpdated(LobbyDataUpdate_t callback) { if (callback.Success == 1) //1 if success, 0 if failure { if (ManualLobbyDataCallbacks.ContainsKey(callback.SteamIDLobby)) { ManualLobbyDataCallbacks[callback.SteamIDLobby]?.Invoke(Lobby.FromSteam(client, callback.SteamIDLobby)); } //find the lobby that has been updated Lobby lobby = Lobbies.Find(x => x != null && x.LobbyID == callback.SteamIDLobby); //if this lobby isn't yet in the list of lobbies, we know that we should add it if (lobby == null) { if (requests.Contains(callback.SteamIDLobby)) { lobby = Lobby.FromSteam(client, callback.SteamIDLobby); Lobbies.Add(lobby); checkFinished(); } } //otherwise lobby data in general was updated and you should listen to see what changed if (requests.Contains(callback.SteamIDLobby)) { OnLobbiesUpdated?.Invoke(); } } }
public void Update() { lock (pendingCallbacks) { foreach (ulong lobbyId in pendingCallbacks) { OnLobbyDataReceived?.Invoke(Lobby.FromSteam(client, lobbyId)); } pendingCallbacks.Clear(); } }
void OnLobbyList(LobbyMatchList_t callback, bool error) { if (error) { return; } //how many lobbies matched uint lobbiesMatching = callback.LobbiesMatching; // lobbies are returned in order of closeness to the user, so add them to the list in that order for (int i = 0; i < lobbiesMatching; i++) { //add the lobby to the list of requests ulong lobby = client.native.matchmaking.GetLobbyByIndex(i); if (requests.Contains(lobby)) { continue; } requests.Add(lobby); //cast to a LobbyList.Lobby Lobby newLobby = Lobby.FromSteam(client, lobby); if (newLobby.Name != "") { //if the lobby is valid add it to the valid return lobbies Lobbies.Add(newLobby); checkFinished(); } else { //else we need to get the info for the missing lobby client.native.matchmaking.RequestLobbyData(lobby); if (!registeredLobbyDataUpdated) { client.RegisterCallback <SteamNative.LobbyDataUpdate_t>(OnLobbyDataUpdated); registeredLobbyDataUpdated = true; } } } checkFinished(); if (OnLobbiesUpdated != null) { OnLobbiesUpdated(); } }
public Lobby GetLobbyFromID(ulong lobbyId) { return(Lobby.FromSteam(client, lobbyId)); }