using EasyCaching.Core;
using IRaCIS.Core.Domain.Share;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;

namespace IRaCIS.Core.API
{
    public interface IUploadClient
    {
        Task ReceivProgressAsync(string studyInstanceUid, int haveReceivedCount);


        Task CompressProgressAsync(Guid visitTaskId, string msg);
    }


    public class IRaCISUserIdProvider : IUserIdProvider
    {
        public virtual string GetUserId(HubConnectionContext connection)
        {
            return connection.User?.FindFirst(JwtIRaCISClaimType.Id)?.Value!;
        }
    }

    [AllowAnonymous]
    [DisableCors]
    public class UploadHub : Hub<IUploadClient>
    {

        public ILogger<UploadHub> _logger { get; set; }

        //public IUserInfo _userInfo { get; set; }
        public UploadHub(/*IUserInfo userInfo,*/ ILogger<UploadHub> logger)
        {
            //_userInfo = userInfo;

            _logger = logger;
        }

        public override Task OnConnectedAsync()
        {
   

            _logger.LogError("连接: " + Context.ConnectionId);


            return base.OnConnectedAsync();
        }



    }
}
