How can I use a value from a session variable as part of the group name in signalR

Posted by user1844734 on Stack Overflow See other posts from Stack Overflow or by user1844734
Published on 2012-11-22T10:45:37Z Indexed on 2012/11/22 11:00 UTC
Read the original article Hit count: 337

Hi I am trying to set up signalR to distribute messages to web users the problem is that the one site holds different 'areas' and also 'user types'.

The Area is decided when the user visits the site by passing a url parameter, this is then stored in a session variable, The 'user type' is by default not logged in then changed when the user logs in to there user type (returned from a webservice) and stored in a User object.

My aim was to connect to the hub using signalR when the user visits the site and add the users connectionId to a groupname, using the 'area id' from the session and the 'user type id' from the User object in the context.

The problem I am having is that I can obtain the user id but when it comes to the area id signalR cannot access the session. I understand the reasoning behind not allowing the session available in signalR but does any one know if there is a way to enable this or an alternative way that I can gain access to the users area so that I can create these unique groups.

© Stack Overflow or respective owner

Related posts about c#-4.0

Related posts about session