asp.net mvc 4 - .done() not getting called on reconnect in signalR -


on mvc4 asp.net web page, have code below within javascript dealing connection server , re-connection server (if connection lost server reason).

the trouble $.connection.hub.start().done() not getting called in response $.connection.hub.start() reconnect (its getting called when issued first time). bug wonder? if not, there equivalent way alert client start() has completed.

// start signalr connection , request default page $.connection.hub.start().done(function () {     console.info("$.connection.hub.start().done");     hubproxy.server.senddefaultpage(); });   //if server goes away - reconnect $.connection.hub.disconnected(function () {     console.info("disconnected");     settimeout(function () {         $.connection.hub.start();     }, 5000); // restart connection after 5 seconds. }); 

you can put connection start logic function:

function startconnection() {     // start signalr connection , request default page     $.connection.hub.start().done(function () {         console.info("$.connection.hub.start().done");         hubproxy.server.senddefaultpage();     }); }  //if server goes away - reconnect $.connection.hub.disconnected(function () {     console.info("disconnected");     settimeout(startconnection, 5000); // restart connection after 5 seconds. }); 

then .done() callback called on both initial connect , reconnect.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -