using Connected.Net.Hubs; using Connected.Net.Messaging; using Connected.Net.Server; using Microsoft.AspNetCore.SignalR.Client; using Microsoft.Extensions.Logging; namespace Connected.Notifications.Events.Server; internal class EventServerConnection : ServerConnection { public event EventHandler? Received; public EventServerConnection(IEndpointServer server, ILogger logger) : base(server) { Logger = logger; } private ILogger Logger { get; } public override async Task Initialize(string hubUrl) { await base.Initialize(hubUrl); Connection.On("Notify", (a, e) => { Connection.InvokeAsync(nameof(EventHub.Acknowledge), a); Received?.Invoke(this, e); }); Connection.On("Exception", (e) => { Logger.LogError("Caching hub exception: {message}", e.Message); }); } }