using Connected.Net.Hubs; using Connected.Net.Messaging; using Connected.Net.Server; using Microsoft.AspNetCore.SignalR.Client; using Microsoft.Extensions.Logging; namespace Connected.Caching.Net; internal class CacheServerConnection : ServerConnection { public event EventHandler? Received; public CacheServerConnection(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(CacheHub.Acknowledge), a); Received?.Invoke(this, e); }); Connection.On("Exception", (e) => { Logger.LogError("Caching hub exception: {message}", e.Message); }); } }