KarizmaConnection is a lightweight abstraction layer built on top of SignalR for .NET Core, designed to eliminate "single hub overload" and simplify the management of requests, actions, and events within a SignalR-based system. It provides a modular and scalable structure, making it easier to handle multiple actions and events across different handlers.
- Modular handling of SignalR requests and events.
- Attribute-based routing for actions and events.
- Simplified client-server interaction using a single hub connection.
To install the package:
dotnet add package KarizmaConnection
-
Define your handlers using attributes:
[RequestHandler("user")] public class UserHandler : BaseRequestHandler { [Action("login")] public Task Login(LoginDto loginData) { /* logic */ } }
-
Add KarizmaConnection to the service collection:
services.AddKarizmaConnection();
-
Initialize the KarizmaConnection hub in WebApplication:
app.MapKarizmaConnectionHub("/mainHub");
[RequestHandler]
: Marks a class as a request handler.[Action]
: Marks a method as an executable action.[EventHandler]
: Marks a method for handling hub events (e.g.,onConnected
,onDisconnected
).
Feel free to contribute by submitting issues or pull requests!