using Hotline.Caching.Interfaces;
using Hotline.CallCenter.Calls;
using Hotline.DI;
using Hotline.Realtimes;
using Hotline.Share.Notifications.NewRockCallCenter;
using MediatR;

namespace Hotline.Application.Handlers.CallCenter.FlowControl
{
    [Injection(EventHandlerType = EEventHandlerType.CallCenter, Label = AppDefaults.CallCenterType.XunShi)]
    public class QueueVisitorToGroupBusyNotificationHandler : INotificationHandler<QueueVisitorToGroupBusyNotification>
    {
        private readonly ICallCacheManager _callCacheManager;
        private readonly IRealtimeService _realtimeService;

        public QueueVisitorToGroupBusyNotificationHandler(ICallCacheManager callCacheManager, IRealtimeService realtimeService)
        {
            _callCacheManager = callCacheManager;
            _realtimeService = realtimeService;
        }

        public async Task Handle(QueueVisitorToGroupBusyNotification notification, CancellationToken cancellationToken)
        {
            await _realtimeService.CallQueueAsync(_callCacheManager.GetCallQueueList(), cancellationToken);
        }
    }
}
