internal package upgrade, changed dispatch href, disabled web client

This commit is contained in:
kkb 2025-02-24 17:27:11 +01:00
parent 3af5a0d107
commit f2a6a67165
39 changed files with 244 additions and 281 deletions

View file

@ -1,57 +1,30 @@
using Insight.Agent.Interfaces;
using Insight.Agent.Messages;
using Microsoft.Extensions.Logging;
using System.Net.Sockets;
using Vaitr.Network;
namespace Insight.Agent.Network
namespace Insight.Agent.Network;
public class AgentSession(IEnumerable<IAgentMessageHandler<AgentSession>> handlers, Socket socket, Stream stream, TcpConnectionOptions options, MemPackSerializer serializer, ILogger<AgentSession> logger)
: TcpSession<MemPackSerializer, IAgentMessage>(socket, stream, options, serializer, logger)
{
public class AgentSession : TcpSession<IAgentMessage>
private readonly IEnumerable<IAgentMessageHandler<AgentSession>> _handlers = handlers;
protected override async ValueTask OnReceivedAsync(PacketContext<IAgentMessage> context, CancellationToken cancellationToken)
{
private readonly IEnumerable<IAgentMessageHandler<AgentSession>> _handlers;
await base.OnReceivedAsync(context, cancellationToken);
public AgentSession(IEnumerable<IAgentMessageHandler<AgentSession>> handlers, ISerializer<IAgentMessage> serializer, ILogger<AgentSession> logger) : base(serializer, logger)
foreach (var handler in _handlers)
{
_handlers = handlers;
}
protected override ValueTask OnConnectedAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Agent ({ep?}) connected", RemoteEndPoint);
return default;
}
protected override ValueTask OnDisconnectedAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Agent ({ep?}) disconnected", RemoteEndPoint);
return default;
}
protected override ValueTask OnSentAsync(IPacketContext<IAgentMessage> context, CancellationToken cancellationToken)
{
return base.OnSentAsync(context, cancellationToken);
}
protected override async ValueTask OnReceivedAsync(IPacketContext<IAgentMessage> context, CancellationToken cancellationToken)
{
await base.OnReceivedAsync(context, cancellationToken);
foreach (var handler in _handlers)
try
{
try
{
await handler.HandleAsync(this, context.Packet, cancellationToken);
}
catch (Exception ex)
{
_logger.LogWarning("Agent ({ep?}) {ex}", RemoteEndPoint, ex.ToString());
}
await handler.HandleAsync(this, context.Data, cancellationToken);
}
catch (Exception ex)
{
_logger.LogWarning("Agent ({ep?}) {ex}", RemoteEndPoint, ex.ToString());
}
}
protected override ValueTask OnHeartbeatAsync(CancellationToken cancellationToken)
{
_logger.LogInformation("Agent ({ep?}) Heartbeat", RemoteEndPoint);
return default;
}
}
}