This commit is contained in:
EonaCat authored and Jeroen Saey committed 2026-11-04 07:53:40 +01:00
1 parent 2c5b69bf2c
commit 22dee59f47
132 files changed
+19653 -7192

No files matched your search

@@ -0,0 +1,50 @@
using System.Collections.Concurrent;
using System.Net;
using System.Security.Cryptography;
namespace EonaCat.Connections.REST
{
public class RestClientConnection : IDisposable
{
public string Id { get; set; } = string.Empty;
public IPEndPoint? RemoteEndPoint { get; set; }
public CancellationTokenSource? CancellationSource { get; set; }
public DateTime ConnectedAt { get; set; }
public DateTime LastActive { get; set; }
public DateTime LastDataSent { get; set; }
public DateTime LastDataReceived { get; set; }
public DateTime LastPingSent { get; set; }
public DateTime LastPongReceived { get; set; }
public long BytesSent { get; set; }
public long BytesReceived { get; set; }
public long MessagesSent { get; set; }
public long MessagesReceived { get; set; }
private string? _nickname;
public string Nickname
{
get => string.IsNullOrWhiteSpace(_nickname) ? Id : _nickname;
set => _nickname = string.IsNullOrWhiteSpace(value) ? Id : value;
}
public bool HasNickname => !string.IsNullOrWhiteSpace(_nickname) && _nickname != Id;
internal ConcurrentQueue<byte[]> PendingMessages { get; } = new();
public int PendingMessageCount => PendingMessages.Count;
public string? WebhookUrl { get; set; }
public Aes? AesInstance { get; set; }
public byte[]? AesSalt { get; set; }
public byte[]? AesIv { get; set; }
public void Dispose()
{
AesInstance?.Dispose();
AesInstance = null;
CancellationSource?.Dispose();
}
}
}