From the course: Learning SignalR with ASP.NET Core

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Send commands from the client

Send commands from the client

From the course: Learning SignalR with ASP.NET Core

Start my 1-month free trial

Send commands from the client

- [Instructor] After you've implemented groups on the hub, a common question is, how does the client request to join a particular group? It turns out, there's not built-in way for the client to ask to be added to a group because for security reasons, we don't want the client to be able to make that decision. Adding or removing connections from groups is always done at the hub level. If you're application allows users to pick a channel to join, then you could create a method on the hub that clients can call. You could create something like RequestToJoin and give a channel name, for example. It's still important that the hub double check to make sure that this particular connection is allowed to join that particular group. In our support chat application, we explicitly do not want the client to be able to join other groups and eavesdrop on visitors. However, it would be nice to let the client pass the name of the visitor to the hub, so the room could be given a useful name. Instead of…

Contents