You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
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<CacheNotificationArgs>? Received;
|
|
|
|
|
|
|
|
|
|
public CacheServerConnection(IEndpointServer server, ILogger<CacheServerConnection> logger) : base(server)
|
|
|
|
|
{
|
|
|
|
|
Logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ILogger<CacheServerConnection> Logger { get; }
|
|
|
|
|
|
|
|
|
|
public override async Task Initialize(string hubUrl)
|
|
|
|
|
{
|
|
|
|
|
await base.Initialize(hubUrl);
|
|
|
|
|
|
|
|
|
|
Connection.On<MessageAcknowledgeArgs, CacheNotificationArgs>("Notify", (a, e) =>
|
|
|
|
|
{
|
|
|
|
|
Connection.InvokeAsync(nameof(CacheHub.Acknowledge), a);
|
|
|
|
|
|
|
|
|
|
Received?.Invoke(this, e);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Connection.On<ServerExceptionArgs>("Exception", (e) =>
|
|
|
|
|
{
|
|
|
|
|
Logger.LogError("Caching hub exception: {message}", e.Message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|