public sealed record UserConnectionModel
{
private readonly CancellationTokenSource cancellationTokenSource;
public UserConnectionModel(CancellationTokenSource cancellationTokenSource)
{
this.cancellationTokenSource = cancellationTokenSource;
AddedDateTime = DateTime.Now;
}
public required string SessionId { get; init; }
public required string ConnectionId { get; init; }
public required string ResourceIdentity { get; init; }
public IReadOnlyCollection<string> ResourceGroupIdentities { get; init; } = [];
public DateTime AddedDateTime { get; init; }
public DateTime? DisconnectedDateTime { get; set; }
public required int TimezoneOffset { get; set; }
public required HttpContext ConnectionContext { get; init; }
public Task CloseConnectionAsync() => cancellationTokenSource.CancelAsync();
public Task SendEventAsync(object data) => ConnectionContext.Response.WriteAsync($"data: {data}\n\n");
}