{"id":28997812,"url":"https://github.com/open-net-libraries/open.signalr.sharedclient","last_synced_at":"2026-02-12T05:33:17.993Z","repository":{"id":277026919,"uuid":"929184202","full_name":"Open-NET-Libraries/Open.SignalR.SharedClient","owner":"Open-NET-Libraries","description":"A HubConnection adapter and provider for easily sharing SignalR connections.","archived":false,"fork":false,"pushed_at":"2025-02-13T20:58:52.000Z","size":793,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-19T22:53:02.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Open-NET-Libraries.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-08T00:54:05.000Z","updated_at":"2025-02-11T18:16:57.000Z","dependencies_parsed_at":"2025-02-11T19:01:56.020Z","dependency_job_id":null,"html_url":"https://github.com/Open-NET-Libraries/Open.SignalR.SharedClient","commit_stats":null,"previous_names":["open-net-libraries/open.signalr.sharedclient"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Open-NET-Libraries/Open.SignalR.SharedClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-NET-Libraries%2FOpen.SignalR.SharedClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-NET-Libraries%2FOpen.SignalR.SharedClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-NET-Libraries%2FOpen.SignalR.SharedClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-NET-Libraries%2FOpen.SignalR.SharedClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Open-NET-Libraries","download_url":"https://codeload.github.com/Open-NET-Libraries/Open.SignalR.SharedClient/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-NET-Libraries%2FOpen.SignalR.SharedClient/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265444278,"owners_count":23766426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-25T06:30:48.472Z","updated_at":"2026-02-12T05:33:17.964Z","avatar_url":"https://github.com/Open-NET-Libraries.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Open.SignalR.SharedClient\n\n[![NuGet](https://img.shields.io/nuget/v/Open.SignalR.SharedClient.svg)](https://www.nuget.org/packages/Open.SignalR.SharedClient/)\n\nA scoped hub connection and provider for easily sharing SignalR connections.\n\n## `IScopedHubConnection`\n\nProvides all the same functionality as a `HubConnection`, \nbut does not interfere with other `IScopedHubConnection` instances.\n\nDisposing the scoped connection cleans up all the handlers\nbut leaves the connection intact for others to use.\n\n## Usage\n\n### DI Setup\n\n#### Default\n\nAssumes the consumers will know which URL to ask for.\n\n```csharp\nservices.AddScopedHubConnectionProvider();\n```\n\nConsumers use `.GetConnectionFor(url)` to get a hub connection.\n\n\n#### With Named Connections\n\nAllows for any hub configuration to be added and retrieved by name.\n\n\u003e Note: Client/Server hybrid apps will need to replicate the DI setup on the server side.\n\n```csharp\nservices.AddScopedHubConnectionProvider(serviceProvider =\u003e {\n\tvar nav = serviceProvider.GetRequiredService\u003cNavigationManager\u003e();\n\treturn [\n\t\t// Hub 1\n\t\tKeyValuePair.Create(\"hub1\",\n\t\t\tnew HubConnectionBuilder()\n\t\t\t.WithAutomaticReconnect()\n\t\t\t.WithUrl(nav.ToAbsoluteUri(\"/hubs/hub1\"))),\n\n\t\t// Hub 2\n\t\tKeyValuePair.Create(\"hub2\",\n\t\t\tnew HubConnectionBuilder()\n\t\t\t.WithUrl(nav.ToAbsoluteUri(\"/hubs/hub2\")))\n\t];\n});\n```\n\nConsumers use `.GetGonnectionByName(hubName)` to get a hub connection.\n\n### Example\n\n\n```csharp\npublic class MyService : IDisposable\n{\n\tprivate readonly IScopedHubConnection _hub;\n\tpublic MyService(IScopedHubConnectionProvider connectionProvider)\n\t{\n\t\t_hub = connectionProvider.GetConnectionByNam(\"hub1\");\n\n\t\t_hub.On(\"MyMethod1\", (string arg1, string arg2) =\u003e\n\t\t{\n\t\t\t// Do something when the method is invoked on the hub.\n\t\t});\n\n\t\t_hub.On(\"MyMethod2\", (string arg1, string arg2) =\u003e\n\t\t{\n\t\t\t// Do something when the method is invoked on the hub.\n\t\t});\n\n\t\t// Automatically invokes OnConnectionEstablished when a connnection is available\n\t\t// and invokes it on every reconnection.\n\t\t_hub.OnConnected(OnConnectionEstablished);\n\t}\n\n\tpublic void Dispose() =\u003e _hub.Dispose();\n\n\tstatic void OnConnectionEstablished(IScopedHubConnection hub)\n\t{\n\t\thub.SendAsync(\"SubTo\", \"MyMethod1\");\n\t\thub.SendAsync(\"SubTo\", \"MyMethod2\");\n\t}\n\n\tpublic async Task DoSomething()\n\t{\n\t\t// Automatically guarantees a connection and invokes the method.\n\t\tawait _hub.InvokeAsync(\"MyMethod\", \"arg1\", \"arg2\");\n\t}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-net-libraries%2Fopen.signalr.sharedclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-net-libraries%2Fopen.signalr.sharedclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-net-libraries%2Fopen.signalr.sharedclient/lists"}