In a browser-based app, cookie authentication allows your existing user credentials to automatically flow to SignalR connections. When using the browser client, no additional configuration is needed. If the user is logged in to your app, the SignalR connection automatically inherits this authentication.
Handle the disconnected event to display a message when an attempt to reconnect has timed out. In this scenario, the only way to re-establish a connection with the server again is to restart the SignalR connection by calling the Start method, which will create a new connection ID.
When using SignalR hubs you can use the HubCallerContext.User
property to:
Gets the user that was part of the initial http request.
So try it with:
public Task Join()
{
string username = Context.User.Identity.Name;
//find group based on username
string group = getGroup(username)
return Groups.Add(Context.ConnectionId, group);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With