I have multiple javascript blocks with signalR functions.
I don\'t know the order of execution so that i want to start the hub with
$.connection.hub.st
You can detect when the hub has started using .done()
$.connection.hub.start().done(function () {
});
using this method, you can do the following (Taken from docs : https://github.com/SignalR/SignalR/wiki/SignalR-JS-Client-Hubs) you can then keep track of if the connection is open yourself.
function connectionReady() {
alert("Done calling first hub serverside-function");
};
$.connection.hub.start()
.done(function() {
myHub.server.SomeFunction(SomeParam) //e.g. a login or init
.done(connectionReady);
})
.fail(function() {
alert("Could not Connect!");
});