Implementing admin-controlled group management in SignalR
In this recipe, we will explore SignalR groups. Groups can be a way to not only organize users but also isolate their interactions from one another. We will also have a special admin user – who is the only one who can add and remove users from a group.
Getting ready
The starter project for this recipe can be found here: https://github.com/PacktPublishing/ASP.NET-9-Web-API-Cookbook/tree/main/start/chapter06/Groups/SignalRServer.
How to do it…
- In the
Services
folder, create a file calledICustomGroupManager.cs
and fill in theICustomGroupManager
interface:public interface ICustomGroupManager { Task AddUserToGroup(string username, string groupName); Task RemoveUserFromGroup(string username, string groupName); Task<IEnumerable<string>> GetUserGroups(string username); }
- In the same folder, create a file called
CustomGroupManager...