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).
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using System.Threading.Tasks;
|
|
|
|
namespace Siegebreak.Services
|
|
{
|
|
/// <summary>
|
|
/// HTTP client for the backend `economy` module: the store catalog, the
|
|
/// player's wallet, and purchase validation. Gems are granted server-side
|
|
/// from the verified receipt, so the client only forwards the store receipt
|
|
/// and reflects the result.
|
|
/// </summary>
|
|
public class EconomyClient
|
|
{
|
|
public async Task<Product[]> GetProducts()
|
|
{
|
|
var res = await HttpApi.GetArrayAsync<Product>("/economy/products", auth: false);
|
|
return res.Success ? res.Data : System.Array.Empty<Product>();
|
|
}
|
|
|
|
public async Task<Wallet> GetWallet()
|
|
{
|
|
var res = await HttpApi.GetAsync<Wallet>("/economy/wallet", auth: true);
|
|
return res.Success ? res.Data : null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Submit a store receipt for verification. Returns the grant result on
|
|
/// success, or null if the receipt was rejected/failed verification —
|
|
/// callers must not credit anything themselves; the server is
|
|
/// authoritative.
|
|
/// </summary>
|
|
public async Task<PurchaseResult> ValidatePurchase(string platform, string receipt)
|
|
{
|
|
string body = HttpApi.JsonUtilityBody(
|
|
new PurchaseRequest { platform = platform, receipt = receipt });
|
|
var res = await HttpApi.PostAsync<PurchaseResult>(
|
|
"/economy/purchase/validate", body, auth: true);
|
|
return res.Success ? res.Data : null;
|
|
}
|
|
}
|
|
}
|