https://github.com/dimesoftware/websockets
🛰️ Stay on top of SignalR connections with connection trackers
https://github.com/dimesoftware/websockets
csharp dotnet signalr websockets
Last synced: 9 days ago
JSON representation
🛰️ Stay on top of SignalR connections with connection trackers
- Host: GitHub
- URL: https://github.com/dimesoftware/websockets
- Owner: dimesoftware
- License: mit
- Created: 2020-04-30T20:10:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-11-23T15:40:29.000Z (5 months ago)
- Last Synced: 2025-12-12T01:44:41.379Z (5 months ago)
- Topics: csharp, dotnet, signalr, websockets
- Language: C#
- Homepage:
- Size: 63.5 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

WebSockets
[](https://dev.azure.com/dimesoftware/Utilities/_build/latest?definitionId=176&branchName=master) 
This is a lightweight project that can be used to keep track of SignalR connections. This is useful in multi-tenant instances where you don't want to broadcast data to other tenants. It hooks into SignalR and allows you to overwrite the default workflow.
## Getting Started
- You must have Visual Studio 2019 Community or higher.
- The dotnet cli is also highly recommended.
## About this project
This project provides a simple interface and a few implementations for that interface. This makes it configurable and easy to setup in the startup of the application. For example, it requires only 1 line of code to swap an in-memory connection tracker with a SQL connection tracker.
## Installation
> 🚧 Warning: the packages are not available yet on NuGet.
Use the package manager NuGet to install the base library:
`dotnet add package Dime.WebSockets`
Next it is up to you to decide which _persistence medium_ you want to use:
| Service | Command |
| --------------- | --------------------------------------------- |
| In memory cache | `dotnet add package Dime.WebSockets.InMemory` |
| Sql | `dotnet add package Dime.WebSockets.Sql` |
| Redis | `dotnet add package Dime.WebSockets.Redis` |
## Usage
When a user connects, the connection can be stored in the connection tracker's storage medium. This data can be retrieved when the hub broadcasts data to the clients.
```csharp
public class MyHub : Hub
{
private readonly IConnectionTracker _connectionTracker;
public MyHub(IConnectionTracker connectionTracker)
{
_connectionTracker = connectionTracker;
}
public override async Task OnConnected()
{
await this.ConnectionTracker.AddAsync(new Connection(){ ConnectionId = Context.ConnectionId });
}
}
```
## Contributing

Pull requests are welcome. Please check out the contribution and code of conduct guidelines.
## License
