using System;
using Com.Project.B.Authorize;
using Cysharp.Threading.Tasks;

namespace Project.B.Authorize
{
    /// <summary>
    /// 授权服务
    /// </summary>
    public interface IAuthorizeService
    {
        /// <summary>
        /// 尝试获取授权数据
        /// </summary>
        /// <param name="playerId"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        bool TryGetAuthorizeData(Guid playerId, out IAuthorizeData data);
        UniTask<IAuthorizeData[]> GetAllAuthorizeDataAsync();
        /// <summary>
        /// 授权和登录
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        UniTask<IAuthorizeData> AuthorizeAsync(IAuthorizeData data);
        /// <summary>
        /// 保持心跳,超时则断开链接
        /// </summary>
        /// <param name="playerId"></param>
        /// <param name="connectionId"></param>
        /// <returns></returns>
        UniTask<bool> HeartbeatAsync(Guid playerId,int connectionId);
        /// <summary>
        /// 授权成功回调
        /// </summary>
        event Action<IAuthorizeData> OnAuthorized;
        /// <summary>
        /// 授权超时回调
        /// </summary>
        event Action<IAuthorizeData> OnAuthorizeTimeout; 
    }
}

