Repeat signalR authenticate
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
e964fa72f3
commit
9fbc946c68
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { IEventMessage } from '../models/event.message';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Subject, timer } from 'rxjs';
|
||||
import { OAuthService } from 'angular-oauth2-oidc';
|
||||
import { HubConnection, HubConnectionBuilder, LogLevel ,HttpTransportType} from '@microsoft/signalr';
|
||||
import { AppConfig } from "../shared/app.config";
|
||||
@ -14,6 +14,7 @@ export class EventService {
|
||||
public event:Subject <IEventMessage> = new Subject<IEventMessage>();
|
||||
private _connection: HubConnection = null;
|
||||
private _apiEndPoint: string;
|
||||
public authenticated:boolean = false;
|
||||
|
||||
constructor(private oauthService: OAuthService, private appConfig: AppConfig) {
|
||||
this._apiEndPoint = appConfig.getConfig("apiEndPoint");
|
||||
@ -39,6 +40,12 @@ export class EventService {
|
||||
var accessToken = this.oauthService.getAccessToken();
|
||||
if (accessToken) {
|
||||
this._connection.send('authenticate', this.oauthService.getAccessToken());
|
||||
this.authenticated=true;
|
||||
} else {
|
||||
//try again after half a second
|
||||
setTimeout(() => {
|
||||
this.Authenticate();
|
||||
}, 800);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user