1- import * as SignalR from "@aspnet /signalr" ;
1+ import * as SignalR from "@microsoft /signalr" ;
22import { AppEvents } from './app.common' ;
33
44class SignalRApp {
@@ -18,6 +18,7 @@ class SignalRApp {
1818 this . connection = new SignalR . HubConnectionBuilder ( )
1919 . withUrl ( options . url , options )
2020 . configureLogging ( SignalR . LogLevel . Information )
21+ . withAutomaticReconnect ( [ 0 , 3000 , 5000 , 10000 , 15000 , 30000 ] )
2122 . build ( ) ;
2223
2324 //Receive Data
@@ -29,6 +30,22 @@ class SignalRApp {
2930 self . processResponse . call ( self . connection , data ) ;
3031 self . HandleResponse ( data ) ;
3132 }
33+
34+ self . connection . onreconnecting ( ( error ) => {
35+ // disableUi(true);
36+ // const li = document.createElement("li");
37+ // li.textContent = `Connection lost due to error "${error}". Reconnecting.`;
38+ // document.getElementById("messagesList").appendChild(li);
39+ console . log ( 'On Reconnecting...' ) ;
40+ } ) ;
41+
42+ self . connection . onreconnected ( ( connectionId ) => {
43+ // disableUi(false);
44+ // const li = document.createElement("li");
45+ // li.textContent = `Connection reestablished. Connected.`;
46+ // document.getElementById("messagesList").appendChild(li);
47+ console . log ( 'On Reconnected...' ) ;
48+ } ) ;
3249
3350 AppEvents . emit ( 'Init' , options ) ;
3451 AppEvents . emit ( 'Logger' , "Init" ) ;
0 commit comments