Skip to content

Commit

Permalink
fix: Retrieve unfinished matches only for the current version of the …
Browse files Browse the repository at this point in the history
…game
  • Loading branch information
Dawid Sygocki committed Sep 8, 2023
1 parent db5b99e commit 37e3984
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Runtime/Communication/Matchmaker/MatchmakerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal abstract class MatchmakerClient : IMatchmakerEvents

private string GetUnfinishedMatchesUrl(Guid gameId, string gameVersion)
{
_uriBuilder.Path = string.Join("/", _baseUrlOriginalPath, MatchmakingRoutes.Base, MatchmakingRoutes.UnfinishedMatches, gameId.ToString(), gameVersion);
_uriBuilder.Path = string.Join("/", _baseUrlOriginalPath, MatchmakingRoutes.Base, MatchmakingRoutes.Unfinished, gameId.ToString(), gameVersion);
return _uriBuilder.Uri.ToString();
}

Expand All @@ -39,7 +39,7 @@ public void CheckForAnyUnfinishedMatch(Guid gameId, string gameVersion, AuthData
void OnResponse(Result<UnfinishedMatchesResponse, Exception> result)
{
if (result.IsSuccess)
onCompleted((result.Value.MatchIds?.Count ?? 0) > 0);
onCompleted(result.Value.Matches?.Any() is true);
else
onError(result.Error);
}
Expand Down Expand Up @@ -73,7 +73,7 @@ void OnListResponse(Result<UnfinishedMatchesResponse, Exception> result)
return;
}

matchId = result.Value?.MatchIds?.FirstOrDefault();
matchId = result.Value?.Matches?.FirstOrDefault()?.MatchId;
if (string.IsNullOrEmpty(matchId))
{
EmitMatchmakingFailed("No unfinished matches to rejoin", Guid.Empty, gameId, gameVersion);
Expand Down
3 changes: 2 additions & 1 deletion Runtime/Communication/Matchmaker/Models/Routes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public static class Routes

public const string GetMatchLongPolling = "getMatchLongPolling";
public const string GetPendingMatchLongPolling = "getPendingMatchLongPolling";
public const string UnfinishedMatches = "unfinished-matches";

public const string Unfinished = "unfinished";
public const string UnfinishedMatchDetails = "unfinished-match-details";

public const string FindAndJoinMatch = "findAndJoinMatch";
Expand Down
13 changes: 13 additions & 0 deletions Runtime/Communication/Matchmaker/Models/UnfinishedMatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace Elympics.Models.Matchmaking
{
[Serializable]
public class UnfinishedMatch
{
public string MatchId;
public string QueueName;
public string RegionName;
public string InitializedAt;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace Elympics.Models.Matchmaking
[Serializable]
public class UnfinishedMatchesResponse
{
public List<string> MatchIds;
public List<UnfinishedMatch> Matches;
}
}

0 comments on commit 37e3984

Please sign in to comment.