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

29 lines
1.0 KiB
C#

using System.Threading.Tasks;
namespace Siegebreak.Services
{
/// <summary>
/// HTTP client for player-centric reads: the authenticated profile
/// (progression + wallet + win/loss record) and recent match history.
/// </summary>
public class PlayerClient
{
public async Task<PlayerProfile> GetMe()
{
var res = await HttpApi.GetAsync<PlayerProfile>("/players/me", auth: true);
return res.Success ? res.Data : null;
}
/// <summary>
/// Recent matches, newest first. <paramref name="limit"/> is clamped
/// server-side (max 50); pass 0 to use the server default.
/// </summary>
public async Task<MatchHistoryEntry[]> GetMatchHistory(int limit = 0)
{
string path = limit > 0 ? "/players/me/matches?limit=" + limit : "/players/me/matches";
var res = await HttpApi.GetArrayAsync<MatchHistoryEntry>(path, auth: true);
return res.Success ? res.Data : System.Array.Empty<MatchHistoryEntry>();
}
}
}