using System.Text.Json.Serialization; namespace FinalFactory.Rendezvous.Contracts; public sealed class SessionListing { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public SessionListingId ListingId { get; set; } [JsonRequired] public GameId GameId { get; set; } [JsonRequired] public EnvironmentId EnvironmentId { get; set; } [JsonRequired] public RegionId RegionId { get; set; } [JsonRequired] public uint ProtocolVersion { get; set; } [JsonRequired] public string BuildVersion { get; set; } = string.Empty; [JsonRequired] public string DisplayName { get; set; } = string.Empty; [JsonRequired] public ListingVisibility Visibility { get; set; } [JsonRequired] public PublisherTrustMode PublisherTrustMode { get; set; } [JsonRequired] public SessionCapacity Capacity { get; set; } = new(); [JsonRequired] public Dictionary Metadata { get; set; } = new(StringComparer.Ordinal); public NetworkEndpoint? DedicatedFallback { get; set; } } public sealed class RegisterSessionRequest { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public string IdempotencyKey { get; set; } = string.Empty; [JsonRequired] public GameId GameId { get; set; } [JsonRequired] public EnvironmentId EnvironmentId { get; set; } [JsonRequired] public RegionId RegionId { get; set; } [JsonRequired] public uint ProtocolVersion { get; set; } [JsonRequired] public string BuildVersion { get; set; } = string.Empty; [JsonRequired] public string DisplayName { get; set; } = string.Empty; [JsonRequired] public ListingVisibility Visibility { get; set; } [JsonRequired] public SessionCapacity Capacity { get; set; } = new(); [JsonRequired] public Dictionary Metadata { get; set; } = new(StringComparer.Ordinal); public NetworkEndpoint? DedicatedFallback { get; set; } } public sealed class RegisterSessionResponse { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public SessionListingId ListingId { get; set; } [JsonRequired] public LeaseId LeaseId { get; set; } [JsonRequired] public string LeaseToken { get; set; } = string.Empty; [JsonRequired] public MediationHandle HostPresenceHandle { get; set; } [JsonRequired] public string HostPresenceCapability { get; set; } = string.Empty; [JsonRequired] public DateTimeOffset ExpiresAt { get; set; } [JsonRequired] public int LeaseRenewAfterSeconds { get; set; } [JsonRequired] public int HostPresenceRefreshAfterSeconds { get; set; } } public sealed class RenewLeaseRequest { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public string LeaseToken { get; set; } = string.Empty; } public sealed class RenewLeaseResponse { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public DateTimeOffset ExpiresAt { get; set; } [JsonRequired] public int RenewAfterSeconds { get; set; } } public sealed class UpdateSessionRequest { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public string LeaseToken { get; set; } = string.Empty; [JsonRequired] public string BuildVersion { get; set; } = string.Empty; [JsonRequired] public string DisplayName { get; set; } = string.Empty; [JsonRequired] public SessionCapacity Capacity { get; set; } = new(); [JsonRequired] public Dictionary Metadata { get; set; } = new(StringComparer.Ordinal); public NetworkEndpoint? DedicatedFallback { get; set; } } public sealed class DeleteSessionRequest { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public string LeaseToken { get; set; } = string.Empty; } public sealed class BrowseSessionsRequest { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public GameId GameId { get; set; } [JsonRequired] public EnvironmentId EnvironmentId { get; set; } [JsonRequired] public uint ProtocolVersion { get; set; } public RegionId? RegionId { get; set; } public int PageSize { get; set; } = ContractLimits.BrowserPageMaxItems; public bool ExcludeFull { get; set; } public string? Cursor { get; set; } } public sealed class BrowseSessionsResponse { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public List Items { get; set; } = []; public string? NextCursor { get; set; } } public sealed class GetSessionResponse { [JsonRequired] public int ContractVersion { get; set; } = ContractLimits.ContractVersion; [JsonRequired] public SessionListing Session { get; set; } = new(); }