Initial commit.

This commit is contained in:
2026-03-13 10:23:47 +01:00
parent fd81c63020
commit 39c8b861c0
44 changed files with 1144 additions and 4 deletions

View File

@@ -0,0 +1,36 @@
using Microsoft.AspNetCore.SignalR;
namespace ClientApiPoC.Shared.SignalR {
public abstract class TunnelServerBase {
protected IHubContext<TunnelHub> HubContext { get; private set; }
protected ClientTracker Clients { get; private set; }
public TunnelServerBase(IHubContext<TunnelHub> hubContext, ClientTracker clientTracker) {
if (hubContext == null) throw new ArgumentNullException(nameof(hubContext));
if (clientTracker == null) throw new ArgumentNullException(nameof(clientTracker));
this.HubContext = hubContext;
this.Clients = clientTracker;
}
protected ISingleClientProxy? TryGetClient(string clientId) {
ISingleClientProxy? client;
try {
client = this.HubContext.Clients.Client(clientId);
} catch {
client = null;
}
return client;
}
protected IDictionary<string, ISingleClientProxy> GetAllClients() {
var results = new Dictionary<string, ISingleClientProxy>();
var allClientIds = this.Clients.CurrentClientIds;
foreach (var clientId in allClientIds) {
var client = TryGetClient(clientId);
if (client != null) results.Add(clientId, client);
}
return results;
}
}
}