siegebreak/client/Assets/Scripts/Services/MatchmakingClient.cs
caelum0x 2db09f515b feat(client): implement Unity service clients against the real backend
Replaces the NotImplementedException stubs with working clients on the
SDK core:
- AuthClient: guest (stable device id) / apple / google login, storing
  the issued token pair; logout.
- MatchmakingClient: queue / cancel / status.
- SessionClient: fetch the allocated session (room + provider).
- PlayerClient: profile (progression + record) and match history.
- EconomyClient: catalog, wallet, purchase validation.
- MatchSubscription: real-time WS /matchmaking/subscribe with an
  off-thread receive loop drained on the main thread via Update().
- BackendGateway: MonoBehaviour facade owning the clients + subscription.
- NetworkBootstrap.JoinMatch now resolves the backend-allocated session
  and starts the transport against its real room (Photon StartGame is the
  only remaining integration point).
2026-07-30 18:50:09 +03:00

38 lines
1.4 KiB
C#

using System.Threading.Tasks;
namespace Siegebreak.Services
{
/// <summary>
/// HTTP client for the backend `matchmaking` module. Queue/cancel plus a
/// status read used by the polling fallback; the real-time push is handled
/// separately by <see cref="MatchSubscription"/>.
/// </summary>
public class MatchmakingClient
{
/// <summary>Enqueue at the player's rating with the chosen deck.</summary>
public async Task<bool> QueueForMatch(string deckId)
{
string body = HttpApi.JsonUtilityBody(new QueueRequest { deckId = deckId });
var res = await HttpApi.PostAsync<StatusResponse>("/matchmaking/queue", body, auth: true);
return res.Success;
}
public async Task<bool> CancelQueue()
{
var res = await HttpApi.PostRawAsync("/matchmaking/cancel", "{}", auth: true);
return res.Success;
}
/// <summary>
/// Current ticket. Returns null when the request fails; an empty ticket
/// (no status) means "not queued". Callers check <c>IsMatched</c> to
/// know when a session has been allocated.
/// </summary>
public async Task<MatchTicket> GetStatus()
{
var res = await HttpApi.GetAsync<MatchTicket>("/matchmaking/status", auth: true);
return res.Success ? res.Data : null;
}
}
}