//using Hotline.Caching.Interfaces;
//using Hotline.Users;
//using Microsoft.AspNetCore.SignalR;
//using XF.Domain.Authentications;
//using XF.Domain.Exceptions;

//namespace Hotline.Api.Realtimes;

//public class CallCenterHub : Hub
//{
//    private readonly ISessionContext _sessionContext;
//    private readonly IWorkRepository _workRepository;
//    private readonly IUserCacheManager _userCacheManager;

//    public CallCenterHub(
//        ISessionContext sessionContext,
//        IWorkRepository workRepository,
//        IUserCacheManager userCacheManager)
//    {
//        _sessionContext = sessionContext;
//        _workRepository = workRepository;
//        _userCacheManager = userCacheManager;
//    }

//    /// <summary>
//    /// Called when a new connection is established with the hub.
//    /// </summary>
//    /// <returns>A <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous connect.</returns>
//    public override async Task OnConnectedAsync()
//    {
//        var userId = _sessionContext.RequiredUserId;
//        var work = _userCacheManager.GetWorkByUser(userId);
//        if (work == null)
//            throw new UserFriendlyException($"未查询到上班记录, userId: {userId}", "未查询到上班记录");
//        work.SignalRId = Context.ConnectionId;
//        await _workRepository.UpdateAsync(work, Context.ConnectionAborted);
//        _userCacheManager.UpdateWorkByUser(work);
//        await base.OnConnectedAsync();
//    }

//    /// <summary>Called when a connection with the hub is terminated.</summary>
//    /// <returns>A <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous disconnect.</returns>·~·
//    public override Task OnDisconnectedAsync(Exception? exception)
//    {
//        return base.OnDisconnectedAsync(exception);
//    }
//}