using System; using System.Threading; using System.Threading.Tasks; using FrameworkDAL.DTO.EIPConversation; using GB5Shared.DTO.Framework.Login; using Microsoft.Extensions.Logging; namespace FrameworkBLL.EIPConversation.EIPHandlers.ChannelHandler { // ============================================================ // AppChatChannelHandler — IEIPChannelHandler for the AppChat // (in-app SignalR) channel. // // The hub (EIPChatHub) handles actual SignalR delivery directly // after receiving EIPExecutionResultDTO from the BLL, so this // handler exists only to satisfy the response engine's channel // lookup for EIPChannelType.AppChat ("APPCHAT"). It is a // deliberate no-op: it logs the outbound message and returns // success so the pipeline completes cleanly. // // Auto-registered by assembly scan — no manual DI entry needed. // ============================================================ public class AppChatChannelHandler : IEIPChannelHandler { public string ChannelName => "APPCHAT"; private readonly ILogger _logger; public AppChatChannelHandler(ILogger logger) => _logger = logger ?? throw new ArgumentNullException(nameof(logger)); public bool CanHandle(string channel) => string.Equals(channel, ChannelName, StringComparison.OrdinalIgnoreCase); public Task SendAsync( EIPResponseContext context, LoginDTO loginDTO, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); _logger.LogInformation( "AppChatChannelHandler: delivery logged | Recipient={Recipient} | Tenant={Tenant} | Step={Step} | Completed={IsCompleted}", context.Recipient, context.TenantId, context.CurrentStepCode, context.IsCompleted); return Task.FromResult(new EIPChannelResponseDTO { IsSent = true, ExternalMessageId = Guid.NewGuid().ToString(), Status = "APPCHAT_DELIVERED_VIA_HUB" }); } } }