using Insight.Domain.Interfaces;
using Insight.Domain.Network;
using Insight.Domain.Network.Agent.Messages;
using Microsoft.Extensions.Logging;

namespace Insight.Server.Network.Agent.Handlers;

public class CustomHandler : IMessageHandler<AgentSession>
{
    private readonly ILogger<CustomHandler> _logger;

    public CustomHandler(ILogger<CustomHandler> logger)
    {
        _logger = logger;
    }

    public async ValueTask HandleAsync<TMessage>(AgentSession sender, TMessage message, CancellationToken cancellationToken) where TMessage : IMessage
    {
        switch (message)
        {
            case Response response:
                await OnResponseAsync(sender, response, cancellationToken);
                break;
        }
    }

    private async ValueTask OnResponseAsync(AgentSession sender, Response response, CancellationToken cancellationToken)
    {
        _logger.LogWarning($"Response: {response.ResponseData}");
    }
}