I need a global variable "window.myHub" to set which is passed on as parameter to a function(SignalRSetUp) as below: The way it is passed on right now, doesn't set it ! How could this be resolved ?
var args = {
"userObjectId": UserObjectId,
"hubURL": LCSHubApiURL,
"hubName": HubProxyName,
}
var callBackFuncs = {
"ping": PingFunc
}
window.myHub;
var signalRSetUp = new SignalRSetUp(args,callBackFuncs, window.myHub);
SignalRSetUp(argObj,eventFuncs,globalVar)
{
var $self = this;
var connection = $.hubConnection(argObj.hubURL);
var hub = connection.createHubProxy(argObj.hubName);
hub.connection.qs = { "objectid": argObj.userObjectId };
//Wire : Call back functions and the Hub events
for (var e in eventFuncs) {
hub.on(e, eventFuncs[e]);
//hub event fail
}
connection.start()
.done(function () {
globalVar = hub;
})
.fail(function (error) {
console.log('Could not Connect!');
});
}