public void OnFindPendingMatchesRequestSuccess(FindPendingMatchesResponse response) { if (lastBatchOfMatches == null) { lastBatchOfMatches = response.PendingMatches; RemoveAllHostedGames(); } else { if (lastBatchOfMatches == response.PendingMatches) { lastBatchOfMatches = response.PendingMatches; return; } else { RemoveAllHostedGames(); lastBatchOfMatches = response.PendingMatches; } } //Debug.Log("Matches found: " + response.ScriptData.BaseData["matchesFound"]); if (hosting) { string hostDisplayName = gameSparksUserID.myDisplayName; string matchID = ""; string matchShortCode = ""; AddHostedGameToLobbies(hostDisplayName, matchID, matchShortCode); } var pendingMatches = response.PendingMatches.GetEnumerator(); bool endOfMatches = !pendingMatches.MoveNext(); while (!endOfMatches) { // Get match data var matchedPlayers = pendingMatches.Current.MatchedPlayers.GetEnumerator(); matchedPlayers.MoveNext(); if ((bool)matchedPlayers.Current.ParticipantData.BaseData["hosting"]) { string hostDisplayName = matchedPlayers.Current.ParticipantData.BaseData["displayName"].ToString(); string matchID = pendingMatches.Current.Id; string matchShortCode = pendingMatches.Current.MatchShortCode; AddHostedGameToLobbies(hostDisplayName, matchID, matchShortCode); } endOfMatches = !pendingMatches.MoveNext(); } UnblockRefreshInput(); if (hostedGames.Count == 0) { // No pending matches found Debug.Log("No Pending Matches found"); noHostedGamesPanel.SetActive(true); } else { noHostedGamesPanel.SetActive(false); } refreshingLock = false; }
public void OnFindPendingMatchesRequestError(FindPendingMatchesResponse response) { Debug.Log("Find Matches Error: " + response.Errors.JSON); UnblockRefreshInput(); refreshingLock = false; if (ThrottleHandler.IsRequestThrottled(response.Errors.JSON)) { Invoke("AttemptSendFindRequest", ThrottleHandler.GetRandomTime()); } }