11import { Injectable } from '@angular/core' ;
22import { SecurityService } from './security.service' ;
33import { ConfigurationService } from './configuration.service' ;
4- import { HubConnection , HubConnectionBuilder , LogLevel , HttpTransportType } from '@aspnet /signalr' ;
4+ import { HubConnection , HubConnectionBuilder , LogLevel , HttpTransportType } from '@microsoft /signalr' ;
55import { ToastrService } from 'ngx-toastr' ;
66import { Subject } from 'rxjs' ;
77
@@ -25,7 +25,7 @@ export class SignalrService {
2525 this . SignalrHubUrl = this . configurationService . serverSettings . signalrHubUrl ;
2626 this . init ( ) ;
2727 } ) ;
28- }
28+ }
2929 }
3030
3131 public stop ( ) {
@@ -36,16 +36,18 @@ export class SignalrService {
3636 if ( this . securityService . IsAuthorized == true ) {
3737 this . register ( ) ;
3838 this . stablishConnection ( ) ;
39- this . registerHandlers ( ) ;
40- }
39+ this . registerHandlers ( ) ;
40+ }
4141 }
4242
4343 private register ( ) {
4444 this . _hubConnection = new HubConnectionBuilder ( )
4545 . withUrl ( this . SignalrHubUrl + '/hub/notificationhub' , {
46+ transport : HttpTransportType . LongPolling ,
4647 accessTokenFactory : ( ) => this . securityService . GetToken ( )
4748 } )
4849 . configureLogging ( LogLevel . Information )
50+ . withAutomaticReconnect ( )
4951 . build ( ) ;
5052 }
5153
@@ -61,6 +63,7 @@ export class SignalrService {
6163
6264 private registerHandlers ( ) {
6365 this . _hubConnection . on ( 'UpdatedOrderState' , ( msg ) => {
66+ console . log ( `Order ${ msg . orderId } updated to ${ msg . status } ` ) ;
6467 this . toastr . success ( 'Updated to status: ' + msg . status , 'Order Id: ' + msg . orderId ) ;
6568 this . msgSignalrSource . next ( ) ;
6669 } ) ;
0 commit comments