Question

I have a class SignalRConnection. Here I want to generate a connectionId for signalR . I want a new connection Id if the session is null else return the same connection.I tried to implement IhttpHandler for getting the context in the class and IConnectionIdFactory for the connectioId. My Code is Like this:

>  public class SignalRConnection :  
    IHttpHandler,IConnectionIdFactory,IRequireSessionState                                
    {
        string conId;
        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            if (context.Session["activeuser_id"] != null)
            {
                conId = context.Session["activeuser_id"].ToString();
            }
            else
            {
                conId = Guid.NewGuid().ToString();
            }
        }
        public string CreateConnectionId(SignalR.Hosting.IRequest request)
        {
            return conId;
        }
        public string CreateConnectionId(SignalR.Hosting.IRequest request ,string test)
        {
            return conId;
        }
    }

the problem here is the CreateConnectionId is only executed.I have the config file configured for the httphandler.I want the the conId to be generated from ProcessRequest and the the CreateConnectionId serve the ConnectionId to the SignalR Connection.Can It be obtained or am i heading the wrong direction.

Was it helpful?

Solution

IConnectionFactory is no longer supported in the latest version of SignalR. See SignalR 1.0 beta connection factory for recommendations on better ways to get the same behavior.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top