Vipul Patel
Vipul Patel

Reputation: 69

How SignalR manages connection between Postbacks

1> Just want to understand how SignalR 1.x functions in a particular scenario

Lets say we have a 10 clients connected to Hub and one of the connected clients say client-1 performs a postback so OnDisconnected is called than OnConnected is called right ?

What happens if during this phase if client-2 try's to send message to client-1 exactly between the said scenario ie (msg is sent after client-1 is disconnected and before connected again )will client-1 miss the message or there's internal mechanism which makes sure client-1 does not miss the message sent by client-2

2> Second query I have is that I'm trying to pass a querystring using following code

 var chat = $.connection.myHub;
            $.connection.myHub.qs = { "token": "hello" };

but not able to retrieve it on the server side from the Context object using

Context.QueryString.AllKeys

I even tried

 var chat = $.connection.myHub;
            $.connection.myHub.qs =  "token=hello" ;

But it does not work ie when I check the keys, token is not present in AllKeys

Will appreciate if someone just help me out.

Upvotes: 3

Views: 1040

Answers (1)

N. Taylor Mullen
N. Taylor Mullen

Reputation: 18301

1: If a postback occurs a client will disconnect and then connect. However, when the client performs a connect again it will have a different Connection Id than it had prior to the postback. Therefore, any message sent to the old connection id will be missed because when the users browser connects again it will be known as a different client.

2: You're trying to set the query string on the hub proxy, not the connection. What you should be doing is:

$.connection.hub.qs = { foo: "bar" };

Upvotes: 1

Related Questions