Hello,
I found a nice book describing signalR. As we have a somewhat related task at hand (send multiple notifications to specific clients) I found signalR a good fit for the task at hand.
My problem comes from details as it is mostly the case.
I run a timer to poll a database table for new data to be send. Now in our database we have a user table and thus my table carries a userid field so that I can select data only meant for that specific user. I implemented a dictionary <int,string> to map the various userids to their signalR connectionIds so I can then pull the client's connectionId from said dictionary and
string client;
if (!UserConnections.TryGetValue(UserInfo.UserID, out client))
{
return;
}
this.Connection.Send(client, message);
use this code section to send the message to its appropriate client.
Our application is generally a asp net mvc 4 application.
I looked at how controllers get the current user - they instantiate an object that pulls the user's data from the current session (cookie).
Now when I'm in the signalR persistent connection (or a child class thereof) any call to System.Web.HttpContext.Current yields null - which is now clear because the persistent connection doesnt know the default connection.
Instead I found hints to get the hubcontext but sadly at least for now
var requestContext = request.GetHttpContext();
string user = requestContext.User.Identity.Name;
shows "" - simply because I didnt set a name for the client yet. I also doubt that it will be filled with the login-name for the default connection
So is there ANY way to gain access to the properties of the "default connection" that the app built to the browser-window running this instance ?