Reputation: 162
I am writing a core class library for SignalR. I created a class library and I added a SignalR package to that. as you know instances are different how can I use webApplication(Asp.Net-Code) project SignalR instance? Please share with me if you have a sample code thanks a lot
Upvotes: 3
Views: 460
Reputation: 61
Hi I added a singleton class
internal class HubClientsConnectedInfo
{
private IHubCallerClients _clients;
private IGroupManager _groups;
public void Set(IHubCallerClients clients, IGroupManager groups)
{
_clients ??= clients;
_groups ??= groups;
}
public IHubCallerClients Clients => _clients;
public IGroupManager Groups => _groups;
}
then i register it in Program.cs
builder.Services.AddSingleton<HubClientsConnectedInfo>();
then i fill it on BaseHub.OnConnectedAsync
Upvotes: 2