(function($,window,undefined){varresources={nojQuery:"jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file.",noTransportOnInit:"No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization.",errorOnNegotiate:"Error during negotiation request.",stoppedWhileLoading:"The connection was stopped during page load.",stoppedWhileNegotiating:"The connection was stopped during the negotiate request.",errorParsingNegotiateResponse:"Error parsing negotiate response.",errorDuringStartRequest:"Error during start request. Stopping the connection.",stoppedDuringStartRequest:"The connection was stopped during the start request.",errorParsingStartResponse:"Error parsing start response: '{0}'. Stopping the connection.",invalidStartResponse:"Invalid start response: '{0}'. Stopping the connection.",protocolIncompatible:"You are using a version of the client that isn't compatible with the server. Client version {0}, server version {1}.",sendFailed:"Send failed.",parseFailed:"Failed at parsing response: {0}",longPollFailed:"Long polling request failed.",eventSourceFailedToConnect:"EventSource failed to connect.",eventSourceError:"Error raised by EventSource",webSocketClosed:"WebSocket closed.",pingServerFailedInvalidResponse:"Invalid ping response when pinging server: '{0}'.",pingServerFailed:"Failed to ping server.",pingServerFailedStatusCode:"Failed to ping server. Server responded with status code {0}, stopping the connection.",pingServerFailedParse:"Failed to parse ping server response, stopping the connection.",noConnectionTransport:"Connection is in an invalid state, there is no transport active.",webSocketsInvalidState:"The Web Socket transport is in an invalid state, transitioning into reconnecting.",reconnectTimeout:"Couldn't reconnect within the configured timeout of {0} ms, disconnecting.",reconnectWindowTimeout:"The client has been inactive since {0} and it has exceeded the inactivity timeout of {1} ms. Stopping the connection."};if(typeof($)!=="function"){thrownewError(resources.nojQuery);}
returnfalse;},isDisconnecting=function(connection){returnconnection.state===signalR.connectionState.disconnected;},supportsKeepAlive=function(connection){returnconnection._.keepAliveData.activated&&connection.transport.supportsKeepAlive(connection);},configureStopReconnectingTimeout=function(connection){varstopReconnectingTimeout,onReconnectTimeout;if(!connection._.configuredStopReconnectingTimeout){onReconnectTimeout=function(connection){varmessage=signalR._.format(signalR.resources.reconnectTimeout,connection.disconnectTimeout);connection.log(message);$(connection).triggerHandler(events.onError,[signalR._.error(message,"TimeoutException")]);connection.stop(false,false);};connection.reconnecting(function(){varconnection=this;if(connection.state===signalR.connectionState.reconnecting){stopReconnectingTimeout=window.setTimeout(function(){onReconnectTimeout(connection);},connection.disconnectTimeout);}});connection.stateChanged(function(data){if(data.oldState===signalR.connectionState.reconnecting){window.clearTimeout(stopReconnectingTimeout);}});connection._.configuredStopReconnectingTimeout=true;}};signalR=function(url,qs,logging){returnnewsignalR.fn.init(url,qs,logging);};signalR._={defaultContentType:"application/x-www-form-urlencoded; charset=UTF-8",ieVersion:(function(){varversion,matches;if(window.navigator.appName==='Microsoft Internet Explorer'){matches=/MSIE ([0-9]+\.[0-9]+)/.exec(window.navigator.userAgent);if(matches){version=window.parseFloat(matches[1]);}}
returnparseInt(matches[1],10);},configurePingInterval:function(connection){varconfig=connection._.config,onFail=function(error){$(connection).triggerHandler(events.onError,[error]);};if(config&&!connection._.pingIntervalId&&config.pingInterval){connection._.pingIntervalId=window.setInterval(function(){signalR.transports._logic.pingServer(connection).fail(onFail);},config.pingInterval);}}};signalR.events=events;signalR.resources=resources;signalR.ajaxDefaults=ajaxDefaults;signalR.changeState=changeState;signalR.isDisconnecting=isDisconnecting;signalR.connectionState={connecting:0,connected:1,reconnecting:2,disconnected:4};signalR.hub={start:function(){thrownewError("SignalR: Error loading hubs. Ensure your hubs reference is correct, e.g. <script src='/signalr/js'></script>.");}};if(typeof_pageWindow.on=="function"){_pageWindow.on("load",function(){_pageLoaded=true;});}
functionvalidateTransport(requestedTransport,connection){if($.isArray(requestedTransport)){for(vari=requestedTransport.length-1;i>=0;i--){vartransport=requestedTransport[i];if($.type(transport)!=="string"||!signalR.transports[transport]){connection.log("Invalid transport: "+transport+", removing it from the transports list.");requestedTransport.splice(i,1);}}
if(requestedTransport.length===0){connection.log("No transports remain within the specified transport array.");requestedTransport=null;}}elseif(!signalR.transports[requestedTransport]&&requestedTransport!=="auto"){connection.log("Invalid transport: "+requestedTransport.toString()+".");requestedTransport=null;}elseif(requestedTransport==="auto"&&signalR._.ieVersion<=8){return["longPolling"];}
link=window.document.createElement("a");link.href=url;returnlink.protocol+addDefaultPort(link.protocol,link.host)!==against.protocol+addDefaultPort(against.protocol,against.host);},ajaxDataType:"text",contentType:"application/json; charset=UTF-8",logging:false,state:signalR.connectionState.disconnected,clientProtocol:"1.5",reconnectDelay:2000,transportConnectTimeout:0,disconnectTimeout:30000,reconnectWindow:30000,keepAliveWarnAt:2/3,start:function(options,callback){varconnection=this,config={pingInterval:300000,waitForPageLoad:true,transport:"auto",jsonp:false},initialize,deferred=connection._deferral||$.Deferred(),parser=window.document.createElement("a");connection.lastError=null;connection._deferral=deferred;if(!connection.json){thrownewError("SignalR: No JSON parser found. Please ensure json2.js is referenced before the SignalR.js file if you need to support clients without native JSON parsing support, e.g. IE<8.");}
if(connection.url.indexOf("//")===0){connection.url=window.location.protocol+connection.url;connection.log("Protocol relative URL detected, normalizing it to '"+connection.url+"'.");}
deferred.resolve(connection);});connection._.initHandler=signalR.transports._logic.initHandler(connection);initialize=function(transports,index){varnoTransportError=signalR._.error(resources.noTransportOnInit);index=index||0;if(index>=transports.length){if(index===0){connection.log("No transports supported by the server were selected.");}elseif(index===1){connection.log("No fallback transports were selected.");}else{connection.log("Fallback transports exhausted.");}
vartransportName=transports[index],transport=signalR.transports[transportName],onFallback=function(){initialize(transports,index+1);};connection.transport=transport;try{connection._.initHandler.start(transport,function(){varisFirefox11OrGreater=signalR._.firefoxMajorVersion(window.navigator.userAgent)>=11,asyncAbort=!!connection.withCredentials&&isFirefox11OrGreater;connection.log("The start request succeeded. Transitioning to the connected state.");if(supportsKeepAlive(connection)){signalR.transports._logic.monitorKeepAlive(connection);}
signalR.transports._logic.startHeartbeat(connection);signalR._.configurePingInterval(connection);if(!changeState(connection,signalR.connectionState.connecting,signalR.connectionState.connected)){connection.log("WARNING! The connection was not in the connecting state.");}
connection._.connectingMessageBuffer.drain();$(connection).triggerHandler(events.onStart);_pageWindow.bind("unload",function(){connection.log("Window unloading, stopping the connection.");connection.stop(asyncAbort);});if(isFirefox11OrGreater){_pageWindow.bind("beforeunload",function(){window.setTimeout(function(){connection.stop(asyncAbort);},0);});}},onFallback);}
catch(error){connection.log(transport.name+" transport threw '"+error.message+"' when attempting to start.");onFallback();}};varurl=connection.url+"/negotiate",onFailed=function(error,connection){varerr=signalR._.error(resources.errorOnNegotiate,error,connection._.negotiateRequest);$(connection).triggerHandler(events.onError,err);deferred.reject(err);connection.stop();};$(connection).triggerHandler(events.onStarting);url=signalR.transports._logic.prepareQueryString(connection,url);connection.log("Negotiating with '"+url+"'.");connection._.negotiateRequest=signalR.transports._logic.ajax(connection,{url:url,error:function(error,statusText){if(statusText!==_negotiateAbortText){onFailed(error,connection);}else{deferred.reject(signalR._.error(resources.stoppedWhileNegotiating,null,connection._.negotiateRequest));}},success:function(result){varres,keepAliveData,protocolError,transports=[],supportedTransports=[];try{res=connection._parseResponse(result);}catch(error){onFailed(signalR._.error(resources.errorParsingNegotiateResponse,error),connection);return;}
initialize(transports);}});returndeferred.promise();},starting:function(callback){varconnection=this;$(connection).bind(events.onStarting,function(e,data){callback.call(connection);});returnconnection;},send:function(data){varconnection=this;if(connection.state===signalR.connectionState.disconnected){thrownewError("SignalR: Connection must be started before data can be sent. Call .start() before .send()");}
if(connection.state===signalR.connectionState.connecting){thrownewError("SignalR: Connection has not been fully initialized. Use .start().done() or .start().fail() to run logic after the connection has started.");}
deleteconnection._.config;deleteconnection._.deferredStartHandler;if(!_pageLoaded&&(!connection._.config||connection._.config.waitForPageLoad===true)){connection.log("Stopping connection prior to negotiate.");if(deferral){deferral.reject(signalR._.error(resources.stoppedWhileLoading));}
functioncheckIfAlive(connection){varkeepAliveData=connection._.keepAliveData,timeElapsed;if(connection.state===signalR.connectionState.connected){timeElapsed=newDate().getTime()-connection._.lastMessageAt;if(timeElapsed>=keepAliveData.timeout){connection.log("Keep alive timed out. Notifying transport that connection has been lost.");connection.transport.lostConnection(connection);}elseif(timeElapsed>=keepAliveData.timeoutWarning){if(!keepAliveData.userNotified){connection.log("Keep alive has been missed, connection may be dead/slow.");$(connection).triggerHandler(events.onConnectionSlow);keepAliveData.userNotified=true;}}else{keepAliveData.userNotified=false;}}}
InitHandler.prototype={start:function(transport,onSuccess,onFallback){varthat=this,connection=that.connection,failCalled=false;if(that.startRequested||that.connectionStopped){connection.log("WARNING! "+transport.name+" transport cannot be started. Initialization ongoing or completed.");return;}
connection.log(transport.name+" transport starting.");transport.start(connection,function(){if(!failCalled){that.initReceived(transport,onSuccess);}},function(error){if(!failCalled){failCalled=true;that.transportFailed(transport,error,onFallback);}
return!that.startCompleted||that.connectionStopped;});that.transportTimeoutHandle=window.setTimeout(function(){if(!failCalled){failCalled=true;connection.log(transport.name+" transport timed out when trying to connect.");that.transportFailed(transport,undefined,onFallback);}},connection._.totalTransportConnectTimeout);},stop:function(){this.connectionStopped=true;window.clearTimeout(this.transportTimeoutHandle);signalR.transports._logic.tryAbortStartRequest(this.connection);},initReceived:function(transport,onSuccess){varthat=this,connection=that.connection;if(that.startRequested){connection.log("WARNING! The client received multiple init messages.");return;}
if(that.connectionStopped){return;}
that.startRequested=true;window.clearTimeout(that.transportTimeoutHandle);connection.log(transport.name+" transport connected. Initiating start request.");signalR.transports._logic.ajaxStart(connection,function(){that.startCompleted=true;onSuccess();});},transportFailed:function(transport,error,onFallback){varconnection=this.connection,deferred=connection._deferral,wrappedError;if(this.connectionStopped){return;}
window.clearTimeout(this.transportTimeoutHandle);if(!this.startRequested){transport.stop(connection);connection.log(transport.name+" transport failed to connect. Attempting to fall back.");onFallback();}elseif(!this.startCompleted){wrappedError=signalR._.error(signalR.resources.errorDuringStartRequest,error);connection.log(transport.name+" transport failed during the start request. Stopping the connection.");$(connection).triggerHandler(events.onError,[wrappedError]);if(deferred){deferred.reject(wrappedError);}
thrownewError("Query string property must be either a string or object.");},getUrl:function(connection,transport,reconnecting,poll,ajaxPost){varbaseUrl=transport==="webSockets"?"":connection.baseUrl,url=baseUrl+connection.appRelativeUrl,qs="transport="+transport;if(!ajaxPost&&connection.groupsToken){qs+="&groupsToken="+window.encodeURIComponent(connection.groupsToken);}
if(data.Response==="started"){onSuccess();}else{triggerStartError(signalR._.error(signalR._.format(signalR.resources.invalidStartResponse,result),null,xhr));}},error:function(xhr,statusText,error){if(statusText!==startAbortText){triggerStartError(signalR._.error(signalR.resources.errorDuringStartRequest,error,xhr));}else{connection.log("The start request aborted because connection.stop() was called.");rejectDeferred(signalR._.error(signalR.resources.stoppedDuringStartRequest,null,xhr));}}});},tryAbortStartRequest:function(connection){if(connection._.startRequest){connection._.startRequest.abort(startAbortText);deleteconnection._.startRequest;}},tryInitialize:function(connection,persistentResponse,onInitialized){if(persistentResponse.Initialized&&onInitialized){onInitialized();}elseif(persistentResponse.Initialized){connection.log("WARNING! The client received an init message after reconnecting.");}},triggerReceived:function(connection,data){if(!connection._.connectingMessageBuffer.tryBuffer(data)){$(connection).triggerHandler(events.onReceived,[data]);}},processMessages:function(connection,minData,onInitialized){vardata;transportLogic.markLastMessage(connection);if(minData){data=transportLogic.maximizePersistentResponse(minData);transportLogic.updateGroups(connection,data.GroupsToken);if(data.MessageId){connection.messageId=data.MessageId;}
if(data.Messages){$.each(data.Messages,function(index,message){transportLogic.triggerReceived(connection,message);});transportLogic.tryInitialize(connection,data,onInitialized);}}},monitorKeepAlive:function(connection){varkeepAliveData=connection._.keepAliveData;if(!keepAliveData.monitoring){keepAliveData.monitoring=true;transportLogic.markLastMessage(connection);connection._.keepAliveData.reconnectKeepAliveUpdate=function(){transportLogic.markLastMessage(connection);};$(connection).bind(events.onReconnect,connection._.keepAliveData.reconnectKeepAliveUpdate);connection.log("Now monitoring keep alive with a warning timeout of "+keepAliveData.timeoutWarning+", keep alive timeout of "+keepAliveData.timeout+" and disconnecting timeout of "+connection.disconnectTimeout);}else{connection.log("Tried to monitor keep alive but it's already being monitored.");}},stopMonitoringKeepAlive:function(connection){varkeepAliveData=connection._.keepAliveData;if(keepAliveData.monitoring){keepAliveData.monitoring=false;$(connection).unbind(events.onReconnect,connection._.keepAliveData.reconnectKeepAliveUpdate);connection._.keepAliveData={};connection.log("Stopping the monitoring of the keep alive.");}},startHeartbeat:function(connection){connection._.lastActiveAt=newDate().getTime();beat(connection);},markLastMessage:function(connection){connection._.lastMessageAt=newDate().getTime();},markActive:function(connection){if(transportLogic.verifyLastActive(connection)){connection._.lastActiveAt=newDate().getTime();returntrue;}
transport.stop(connection);if(transportLogic.ensureReconnectingState(connection)){connection.log(transportName+" reconnecting.");transport.start(connection);}},connection.reconnectDelay);}},handleParseFailure:function(connection,result,error,onFailed,context){varwrappedError=signalR._.transportError(signalR._.format(signalR.resources.parseFailed,result),connection.transport,error,context);if(onFailed&&onFailed(wrappedError)){connection.log("Failed to parse server response while attempting to connect.");}else{$(connection).triggerHandler(events.onError,[wrappedError]);connection.stop();}},initHandler:function(connection){returnnewInitHandler(connection);},foreverFrame:{count:0,connections:{}}};}(window.jQuery,window));(function($,window,undefined){varsignalR=$.signalR,events=$.signalR.events,changeState=$.signalR.changeState,transportLogic=signalR.transports._logic;signalR.transports.webSockets={name:"webSockets",supportsKeepAlive:function(){returntrue;},send:function(connection,data){varpayload=transportLogic.stringifySend(connection,data);try{connection.socket.send(payload);}catch(ex){$(connection).triggerHandler(events.onError,[signalR._.transportError(signalR.resources.webSocketsInvalidState,connection.transport,ex,connection.socket),data]);}},start:function(connection,onSuccess,onFailed){varurl,opened=false,that=this,reconnecting=!onSuccess,$connection=$(connection);if(!window.WebSocket){onFailed();return;}
if(data){if($.isEmptyObject(data)||data.M){transportLogic.processMessages(connection,data,onSuccess);}else{transportLogic.triggerReceived(connection,data);}}};}},reconnect:function(connection){transportLogic.reconnect(connection,this.name);},lostConnection:function(connection){this.reconnect(connection);},stop:function(connection){transportLogic.clearReconnectTimeout(connection);if(connection.socket){connection.log("Closing the Websocket.");connection.socket.close();connection.socket=null;}},abort:function(connection,async){transportLogic.ajaxAbort(connection,async);}};}(window.jQuery,window));(function($,window,undefined){varsignalR=$.signalR,events=$.signalR.events,changeState=$.signalR.changeState,transportLogic=signalR.transports._logic,clearReconnectAttemptTimeout=function(connection){window.clearTimeout(connection._.reconnectAttemptTimeoutHandle);deleteconnection._.reconnectAttemptTimeoutHandle;};signalR.transports.serverSentEvents={name:"serverSentEvents",supportsKeepAlive:function(){returntrue;},timeOut:3000,start:function(connection,onSuccess,onFailed){varthat=this,opened=false,$connection=$(connection),reconnecting=!onSuccess,url;if(connection.eventSource){connection.log("The connection already has an event source. Stopping it.");connection.stop();}
if(!window.EventSource){if(onFailed){connection.log("This browser doesn't support SSE.");onFailed();}
return;}
url=transportLogic.getUrl(connection,this.name,reconnecting);try{connection.log("Attempting to connect to SSE endpoint '"+url+"'.");connection.eventSource=newwindow.EventSource(url,{withCredentials:connection.withCredentials});}
catch(e){connection.log("EventSource failed trying to connect with error "+e.Message+".");if(onFailed){onFailed();}else{$connection.triggerHandler(events.onError,[signalR._.transportError(signalR.resources.eventSourceFailedToConnect,connection.transport,e)]);if(reconnecting){that.reconnect(connection);}}
connection.log("EventSource readyState: "+connection.eventSource.readyState+".");if(e.eventPhase===window.EventSource.CLOSED){connection.log("EventSource reconnecting due to the server connection ending.");that.reconnect(connection);}else{connection.log("EventSource error.");$connection.triggerHandler(events.onError,[error]);}},false);},reconnect:function(connection){transportLogic.reconnect(connection,this.name);},lostConnection:function(connection){this.reconnect(connection);},send:function(connection,data){transportLogic.ajaxSend(connection,data);},stop:function(connection){clearReconnectAttemptTimeout(connection);transportLogic.clearReconnectTimeout(connection);if(connection&&connection.eventSource){connection.log("EventSource calling close().");connection.eventSource.close();connection.eventSource=null;deleteconnection.eventSource;}},abort:function(connection,async){transportLogic.ajaxAbort(connection,async);}};}(window.jQuery,window));(function($,window,undefined){varsignalR=$.signalR,events=$.signalR.events,changeState=$.signalR.changeState,transportLogic=signalR.transports._logic,createFrame=function(){varframe=window.document.createElement("iframe");frame.setAttribute("style","position:absolute;top:0;left:0;width:0;height:0;visibility:hidden;");returnframe;},loadPreventer=(function(){varloadingFixIntervalId=null,loadingFixInterval=1000,attachedTo=0;return{prevent:function(){if(signalR._.ieVersion<=8){if(attachedTo===0){loadingFixIntervalId=window.setInterval(function(){vartempFrame=createFrame();window.document.body.appendChild(tempFrame);window.document.body.removeChild(tempFrame);tempFrame=null;},loadingFixInterval);}
if(attachedTo>0){attachedTo--;}}};})();signalR.transports.foreverFrame={name:"foreverFrame",supportsKeepAlive:function(){returntrue;},iframeClearThreshold:50,start:function(connection,onSuccess,onFailed){varthat=this,frameId=(transportLogic.foreverFrame.count+=1),url,frame=createFrame(),frameLoadHandler=function(){connection.log("Forever frame iframe finished loading and is no longer receiving messages.");if(!onFailed||!onFailed()){that.reconnect(connection);}};if(window.EventSource){if(onFailed){connection.log("Forever Frame is not supported by SignalR on browsers with SSE support.");onFailed();}
return;}
frame.setAttribute("data-signalr-connection-id",connection.id);loadPreventer.prevent();url=transportLogic.getUrl(connection,this.name);url+="&frameId="+frameId;window.document.documentElement.appendChild(frame);connection.log("Binding to iframe's load event.");if(frame.addEventListener){frame.addEventListener("load",frameLoadHandler,false);}elseif(frame.attachEvent){frame.attachEvent("onload",frameLoadHandler);}
frame.src=url;transportLogic.foreverFrame.connections[frameId]=connection;connection.frame=frame;connection.frameId=frameId;if(onSuccess){connection.onSuccess=function(){connection.log("Iframe transport started.");onSuccess();};}},reconnect:function(connection){varthat=this;if(transportLogic.isConnectedOrReconnecting(connection)&&transportLogic.verifyLastActive(connection)){window.setTimeout(function(){if(!transportLogic.verifyLastActive(connection)){return;}
if(connection.frame&&transportLogic.ensureReconnectingState(connection)){varframe=connection.frame,src=transportLogic.getUrl(connection,that.name,true)+"&frameId="+connection.frameId;connection.log("Updating iframe src to '"+src+"'.");frame.src=src;}},connection.reconnectDelay);}},lostConnection:function(connection){this.reconnect(connection);},send:function(connection,data){transportLogic.ajaxSend(connection,data);},receive:function(connection,data){varcw,body,response;if(connection.json!==connection._originalJson){data=connection._originalJson.stringify(data);}
deletetransportLogic.foreverFrame.connections[connection.frameId];connection.frame=null;connection.frameId=null;deleteconnection.frame;deleteconnection.frameId;deleteconnection.onSuccess;deleteconnection.frameMessageCount;connection.log("Stopping forever frame.");}},abort:function(connection,async){transportLogic.ajaxAbort(connection,async);},getConnection:function(id){returntransportLogic.foreverFrame.connections[id];},started:function(connection){if(changeState(connection,signalR.connectionState.reconnecting,signalR.connectionState.connected)===true){$(connection).triggerHandler(events.onReconnect);}}};}(window.jQuery,window));(function($,window,undefined){varsignalR=$.signalR,events=$.signalR.events,changeState=$.signalR.changeState,isDisconnecting=$.signalR.isDisconnecting,transportLogic=signalR.transports._logic;signalR.transports.longPolling={name:"longPolling",supportsKeepAlive:function(){returnfalse;},reconnectDelay:3000,start:function(connection,onSuccess,onFailed){varthat=this,fireConnect=function(){fireConnect=$.noop;connection.log("LongPolling connected.");if(onSuccess){onSuccess();}else{connection.log("WARNING! The client received an init message after reconnecting.");}},tryFailConnect=function(error){if(onFailed(error)){connection.log("LongPolling failed to connect.");returntrue;}
returnfalse;},privateData=connection._,reconnectErrors=0,fireReconnected=function(instance){window.clearTimeout(privateData.reconnectTimeoutId);privateData.reconnectTimeoutId=null;if(changeState(instance,signalR.connectionState.reconnecting,signalR.connectionState.connected)===true){instance.log("Raising the reconnect event");$(instance).triggerHandler(events.onReconnect);}},maxFireReconnectedTimeout=3600000;if(connection.pollXhr){connection.log("Polling xhr requests already exists, aborting.");connection.stop();}
connection.log("Opening long polling request to '"+url+"'.");instance.pollXhr=transportLogic.ajax(connection,{xhrFields:{onprogress:function(){transportLogic.markLastMessage(connection);}},url:url,type:"POST",contentType:signalR._.defaultContentType,data:postData,timeout:connection._.pollTimeout,success:function(result){varminData,delay=0,data,shouldReconnect;connection.log("Long poll complete.");reconnectErrors=0;try{minData=connection._parseResponse(result);}
returnthat;},invoke:function(methodName){varthat=this,connection=that.connection,args=$.makeArray(arguments).slice(1),argValues=map(args,getArgValue),data={H:that.hubName,M:methodName,A:argValues,I:connection._.invocationCallbackId},d=$.Deferred(),callback=function(minResult){varresult=that._maximizeHubResponse(minResult),source,error;$.extend(that.state,result.State);if(result.Progress){if(d.notifyWith){d.notifyWith(that,[result.Progress.Data]);}elseif(!connection._.progressjQueryVersionLogged){connection.log("A hub method invocation progress update was received but the version of jQuery in use ("+$.prototype.jquery+") does not support progress updates. Upgrade to jQuery 1.7+ to receive progress notifications.");connection._.progressjQueryVersionLogged=true;}}elseif(result.Error){if(result.StackTrace){connection.log(result.Error+"\n"+result.StackTrace+".");}
source=result.IsHubException?"HubException":"Exception";error=signalR._.error(result.Error,source);error.data=result.ErrorData;connection.log(that.hubName+"."+methodName+" failed to execute. Error: "+error.message);d.rejectWith(that,[error]);}else{connection.log("Invoked "+that.hubName+"."+methodName);d.resolveWith(that,[result.Result]);}};connection._.invocationCallbacks[connection._.invocationCallbackId.toString()]={scope:that,method:callback};connection._.invocationCallbackId+=1;if(!$.isEmptyObject(that.state)){data.S=that.state;}
if(typeof(minData.P)!=='undefined'){dataCallbackId=minData.P.I.toString();callback=connection._.invocationCallbacks[dataCallbackId];if(callback){callback.method.call(callback.scope,minData);}}elseif(typeof(minData.I)!=='undefined'){dataCallbackId=minData.I.toString();callback=connection._.invocationCallbacks[dataCallbackId];if(callback){connection._.invocationCallbacks[dataCallbackId]=null;deleteconnection._.invocationCallbacks[dataCallbackId];callback.method.call(callback.scope,minData);}}else{data=this._maximizeClientHubInvocation(minData);connection.log('Triggering client hub event \''+data.Method+'\' on hub \''+data.Hub+'\'.');hubName=data.Hub.toLowerCase();eventName=data.Method.toLowerCase();proxy=this.proxies[hubName];$.extend(proxy.state,data.State);$(proxy).triggerHandler(makeEventName(eventName),[data.Args]);}});connection.error(function(errData,origData){varcallback,callbackId;if(!origData){return;}
callbackId=origData.I;callback=connection._.invocationCallbacks[callbackId];if(callback){connection._.invocationCallbacks[callbackId]=null;deleteconnection._.invocationCallbacks[callbackId];callback.method.call(callback.scope,{E:errData});}});connection.reconnecting(function(){if(connection.transport&&connection.transport.name==='webSockets'){clearInvocationCallbacks(connection,'Connection started reconnecting before invocation result was received.');}});connection.disconnected(function(){clearInvocationCallbacks(connection,'Connection was disconnected before invocation result was received.');});};hubConnection.fn._maximizeClientHubInvocation=function(minClientHubInvocation){return{Hub:minClientHubInvocation.H,Method:minClientHubInvocation.M,Args:minClientHubInvocation.A,State:minClientHubInvocation.S};};hubConnection.fn._registerSubscribedHubs=function(){varconnection=this;if(!connection._subscribedToHubs){connection._subscribedToHubs=true;connection.starting(function(){varsubscribedHubs=[];$.each(connection.proxies,function(key){if(this.hasSubscriptions()){subscribedHubs.push({name:key});connection.log("Client subscribed to hub '"+key+"'.");}});if(subscribedHubs.length===0){connection.log("No hubs have been subscribed to. The client will not receive data from hubs. To fix, declare at least one client side function prior to connection start for each hub you wish to subscribe to.");}