I have a single hub using In-Memory association between users and connections. This hub has two instances of ConnectionMapping - one for Chat connections, one for Navbar connections. The goal is:
- When a user is on any page other than Chat, they will have one signalR connection open, stored in navbarConnections
- When a user is in Chat, they will have two signalR connections open - one in navbarConnections, one in chatConnections
These work great independently, but together they get a little glitchy. The way my app is structured is with a shell that contains the following (in a layoutVM knockout viewModel):
$.connection.hub.qs = {
"isChat": false,
"username": self.emailAddress(),
"baseUrl": self.baseUrl()
};
// define client methods
$.connection.hub.start().done(function () {
// nothing
});
And then, when chat is loaded within the shell, this is defined (in a chatVm knockout viewmodel):
$.connection.hub.qs = {
"isChat": true,
"username": self.currentUsername(),
"baseUrl": self.baseUrl()
};
$.connection.hub.start().done(function () {
self.chatIsReady(true);
});
The problem that I'm encountering is that the query strings are sometimes incorrect when calls to signalR are made from Chat - it seems the querystring defined in LayoutVm is overriding those in ChatVm. What can I do to resolve this?