Last post Mar 29, 2013 05:35 AM by davidfowl
Mar 28, 2013 01:33 AM|Sona.ar|LINK
managing connection id with authorized user is very troublesome as signalR refreshes connection id with every refresh or page load.
In my MVC app , I have a master page from which most of the view pages inherit. additionally I have a chat window which should be opened in a frame within the master page. For chat to be enabled and for any notification on master page , I need to maintain
2 connection id for same user and make sure that messages goes to the correct connection id . so if there are 2 users online , I will maintain 4 connection id in DB and keep on updating these with every change in client side.
Now suppose there is a scenario where multiple iFrames having chat window opening within master page, this is going to be messy.
is there any way I can assign some connnection id for every connection and retain it till browser window is closed and can I invoke clients.client() method on any other property than connnection id !!
how do we use State property on connection ! and would it help here.
Mar 29, 2013 05:02 AM|davidfowl|LINK
Why is it messy? This is how JabbR (https://jabbr.net/) works.
No you can't assign a connection id.
Mar 29, 2013 05:27 AM|Sona.ar|LINK
ok precise queries
1. How do you save authorized user and connnection id combination , do you save it in some db table ?
2. also if there are multiple frames within a master page, then how do you manage incoming message !
suppose if a user A is chatting with user B, C and D and chat text is displayed in iframe1, iframe2 and ifrmae3 respectively and with signalR these chatframe and master page have different connection id.
so in all User A has four live connection ids......... now user D sends back a message , how do you make sure that it is shown in iframe3 only and not in iframe1 and 2 ???
do you make runtime groups when two user agree to chat ?
3. last but the most imp how do you make sure that when user disconnects , all the connection id related to that user get wiped from the system.
Mar 29, 2013 05:35 AM|davidfowl|LINK
1. In the database (jabbr uses entity framework)
2. The you just need to treat multple iframes like how you would treat multiple devices and things begin to make more sense. Its pretty simple, when you decide who a message is going to you look up each connection id and send to all of them for that user.
Another option is to create a group per user name and add all connection ids for a specific user to that group.
3. Yes, when all connections are gone then the user is gone.
Coming back to my second point:
Imagine your application support clients from a mobile phone, a desktop client and a web browser. If it's no different to having the user on the same webpage with multiple tabs open. If you generalize it, it just works in all scenarios.