@@ -279,7 +279,7 @@ const errorFailedToConnect = new Error("failed to connect");
279279
280280const konsole = {
281281 log : ( message ?: any , ... optionalParams : any [ ] ) => {
282- if ( typeof ( window ) !== 'undefined' && window [ "botchatDebug" ] && message )
282+ if ( typeof ( window ) !== 'undefined' && ( window as any ) [ "botchatDebug" ] && message )
283283 console . log ( message , ... optionalParams ) ;
284284 }
285285}
@@ -298,7 +298,7 @@ export class DirectLine implements IBotConnection {
298298 public activity$ : Observable < Activity > ;
299299
300300 private domain = "https://directline.botframework.com/v3/directline" ;
301- private webSocket ;
301+ private webSocket : boolean ;
302302
303303 private conversationId : string ;
304304 private secret : string ;
@@ -384,10 +384,10 @@ export class DirectLine implements IBotConnection {
384384 return Observable . throw ( errorFailedToConnect ) ;
385385
386386 case ConnectionStatus . ExpiredToken :
387- return Observable . throw ( errorExpiredToken ) ;
387+ return Observable . of ( connectionStatus ) ;
388388
389389 default :
390- return Observable . of ( null ) ;
390+ return Observable . of ( connectionStatus ) ;
391391 }
392392 } )
393393
@@ -598,8 +598,11 @@ export class DirectLine implements IBotConnection {
598598 private pollingGetActivity$ ( ) {
599599 return Observable . interval ( this . pollingInterval )
600600 . combineLatest ( this . checkConnection ( ) )
601- . flatMap ( _ =>
602- Observable . ajax ( {
601+ . flatMap ( ( [ _ , connectionStatus ] ) => {
602+ if ( connectionStatus !== ConnectionStatus . Online )
603+ return Observable . empty < Activity > ( )
604+
605+ return Observable . ajax ( {
603606 method : "GET" ,
604607 url : `${ this . domain } /conversations/${ this . conversationId } /activities?watermark=${ this . watermark } ` ,
605608 timeout,
@@ -622,7 +625,7 @@ export class DirectLine implements IBotConnection {
622625// .do(ajaxResponse => konsole.log("getActivityGroup ajaxResponse", ajaxResponse))
623626 . map ( ajaxResponse => ajaxResponse . response as ActivityGroup )
624627 . flatMap ( activityGroup => this . observableFromActivityGroup ( activityGroup ) )
625- )
628+ } )
626629 . catch ( error => Observable . empty < Activity > ( ) ) ;
627630 }
628631
0 commit comments