#nullable enable
using System;
using System.Threading;
using System.Threading.Tasks;

namespace IGP.UnitySDK
{
    internal interface IIGPMultiplayerAccessProvider
    {
        event Action? RoomAccessAvailable;

        Task<HostedBootstrapContext?> AcquireHostedBootstrapAsync(
            CancellationToken cancellationToken = default);
    }

    internal sealed class HostedBootstrapContext
    {
        internal string RoomId { get; }
        internal int AppId { get; }
        internal string LaunchTicket { get; }
        internal string BootstrapEndpoint { get; }
        internal string BootstrapSecret { get; }
        internal string GeneratedAt { get; }

        internal HostedBootstrapContext(
            string roomId,
            int appId,
            string launchTicket,
            string bootstrapEndpoint,
            string bootstrapSecret,
            string generatedAt)
        {
            RoomId = roomId;
            AppId = appId;
            LaunchTicket = launchTicket;
            BootstrapEndpoint = bootstrapEndpoint;
            BootstrapSecret = bootstrapSecret;
            GeneratedAt = generatedAt;
        }

        public override string ToString() =>
            $"HostedBootstrapContext(AppId={AppId}, RoomId={RoomId}, Credentials=[REDACTED])";
    }
}
