Reputation: 1
Background:
I'm having trouble figuring out why Disconnect is called from a hub that's not yet been initialized.
I have two different MVC views that creates different signal connections:
When a user logs on, he/she is redirected to the ListView where a javascript creates a connection to the ListHub so that the page is aware of events that locks/unlocks items in the list. When the user clicks on an item, a signal is sent to the ListHub and the item is locked by the user. After that, I stop the click from doing the GET request by using event.preventDefault() and it works well.
The problem is... Once the user leaves for another page - or if the page simply is reloaded - the Disconnect method of the DetailsHub is triggered. I don't get why this is happening. Remember, the ListHub is the only active hub thus far. No other Hubs or connections have been initialized. Still, this is the behavior I'm getting.
What I'm trying to achieve
What I'm trying to achieve here is to do something when Disconnect is raised/called on the DetailsHub. I want nothing to happen when the user disconnects from the ListHub.
Upvotes: 0
Views: 1114
Reputation: 221
It's written in signalR project's wiki:
Whenever a client disconnects, the Disconnect method will be invoked on all hubs that implement IDisconnect. When this method is called you can use Context.ConnectionId to access the client that disconnected.
https://github.com/SignalR/SignalR/wiki/Hubs
Upvotes: 1