First functional version
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good

This commit is contained in:
Willem Dantuma
2019-11-04 18:47:15 +01:00
parent cec43a636c
commit bb9fba996f
18 changed files with 283 additions and 100 deletions

View File

@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { IEventMessage } from '../models/event.message';
import { Subject } from 'rxjs';
import { OAuthService } from 'angular-oauth2-oidc';
import { HubConnection, HubConnectionBuilder, LogLevel } from '@aspnet/signalr';
import { HubConnection, HubConnectionBuilder, LogLevel ,HttpTransportType} from '@aspnet/signalr';
import { AppConfig } from "../shared/app.config";
@@ -15,15 +15,21 @@ export class EventService {
constructor(private oauthService: OAuthService, private appConfig: AppConfig) {
this._apiEndPoint = appConfig.getConfig("apiEndPoint");
this._connection = new HubConnectionBuilder().withUrl(`${ this._apiEndPoint}/eventHub`).configureLogging(LogLevel.Information).build();
this._connection = new HubConnectionBuilder().withUrl(`${ this._apiEndPoint}/eventHub`,
{ transport: HttpTransportType.WebSockets,
// accessTokenFactory: () => {
// return oauthService.getAccessToken();
// },
skipNegotiation:true
}).configureLogging(LogLevel.Information).build();
this._connection.on('event', eventMessage => {
this.event.next(eventMessage);
});
this._connection.start().then(() => {
var accessToken = oauthService.getAccessToken();
if (accessToken) {
this._connection.send('authenticate', oauthService.getAccessToken());
}
});
this._connection.on('event', eventMessage => {
this.event.next(eventMessage);
});
});
}
}