Trying to implement signalR into our project.
Currently, have a working version without authentication, the server and client talking successfully via websockets.
All good so far!
The next step was to add the user login id to match to the connection id, this is what I cant figure out.
A user logs into the site, gets to the authenticated page with the HttpContext.User set to our version of iprinciple, which contains various bits of data specific to that user.
This is available to the normal MVC controller for page posts and ajax calls, but not to the Hub controller (my name of where the signalr methods are called).
using something like this:
protected object GetAuthInfo()
{
var user = Context.User;
return new
{
UserName = user.Identity.Name
};
}
However, this Context.User.Identity is null and Context.User is not authorised. It seems to me that the websocket is on a different session and has no knowledge of the initial page load session so no user identity has been setup.