Im trying to use State of hub connectivity to avoid multiple connect per tab. what ive done
so far :
var connection = $.hubConnection("/signalr", { useDefaultPath: false });
connection.client = function () { };
var hub = connection.createHubProxy("NotificationHub");
hub.on("AddMessage", Method);
if (hub && hub.state === $.signalR.connectionState.disconnected) {
connection.start({ jsonp: true })
.done(function () {
hub.invoke("FakeLiveState");
hub.invoke('ConnectionConnectedSaveDB', controllerNameSignalR).done(function () {
}).fail(function (error) {
});
})
.fail(function (a) {
});
connection.disconnected(function () {
setTimeout(function () {
connection.start({ jsonp: true })
.done(function () {
hub.invoke('ConnectionConnectedSaveDB', controllerNameSignalR).done(function () {
}).fail(function (error) {
});
})
.fail(function (a) {
});;
}, 5000);
});
}
but result of hub.state isnt the number that mentioned in documentation :
stateChanged: Raised when the connection state changes. Provides the old state and the new state (Connecting, Connected, Reconnecting, or Disconnected).
the hub.state :