DoStuffWithUmbraco
DoStuffWithUmbraco copied to clipboard
connection id undefined
Hey Kevin, first thank you for this great repo. There's lot of good stuff in here ;)
I have been using the SignalR hub and I was having issues getting the client IDas it was undefined.
My code looked like this:
signalRHub.initHub(hubCallbacks);
function hubCallbacks(hub) {
hub.start();
var id = hub.clientId; //this id is always undefined
}
To make it work I had to return the call to the start method in the hub:
start: function () {
if ($.connection.hub.state !== $.connection.connectionState.disconnected) {
$.connection.hub.stop(true, true)
}
return $.connection.hub.start(); //returns the promise here
}
So then I could use it like this:
hub.start().done(function () {
clientId = $.connection.hub.id; //this clientId is correct
});