Automatic reconnect signalR
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
1532e141b9
commit
e964fa72f3
32
package-lock.json
generated
32
package-lock.json
generated
@ -627,16 +627,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@angular/router/-/router-9.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/router/-/router-9.1.0.tgz",
|
||||||
"integrity": "sha512-cExO1nPnoPFiUJWZ28hTHozPLFoCmqr3xqcM57We0hhKE0esdrO+gRWKRH0EJERukLbU8coPKVhA8daGUpASiQ=="
|
"integrity": "sha512-cExO1nPnoPFiUJWZ28hTHozPLFoCmqr3xqcM57We0hhKE0esdrO+gRWKRH0EJERukLbU8coPKVhA8daGUpASiQ=="
|
||||||
},
|
},
|
||||||
"@aspnet/signalr": {
|
|
||||||
"version": "1.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@aspnet/signalr/-/signalr-1.1.4.tgz",
|
|
||||||
"integrity": "sha512-Jp9nPc8hmmhbG9OKiHe2fOKskBHfg+3Y9foSKHxjgGtyI743hXjGFv3uFlUg503K9f8Ilu63gQt3fDkLICBRyg==",
|
|
||||||
"requires": {
|
|
||||||
"eventsource": "^1.0.7",
|
|
||||||
"request": "^2.88.0",
|
|
||||||
"ws": "^6.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@babel/code-frame": {
|
"@babel/code-frame": {
|
||||||
"version": "7.5.5",
|
"version": "7.5.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
|
||||||
@ -2702,14 +2692,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@farmmaps/common": {
|
"@farmmaps/common": {
|
||||||
"version": "0.0.1-prerelease.234",
|
"version": "0.0.1-prerelease.241",
|
||||||
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common/-/common-0.0.1-prerelease.234.tgz",
|
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common/-/common-0.0.1-prerelease.241.tgz",
|
||||||
"integrity": "sha512-JjMI1nMDZsDnHmGBamBkMMDaB2vlFlpESWRiz0XWqZMkyWCPjxK8KOsPlSUZuwZFSCsD0gk28bTZZlcT+4L4cw=="
|
"integrity": "sha512-GLej5+PJng5uS/OUiKZIe/rREyi/tINn8CVmEH6sROhiMizpXM7k9c8PZN0+oayPfNQ73jzd+FV6EcNt2jOCSw=="
|
||||||
},
|
},
|
||||||
"@farmmaps/common-map": {
|
"@farmmaps/common-map": {
|
||||||
"version": "0.0.1-prerelease.234",
|
"version": "0.0.1-prerelease.241",
|
||||||
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map/-/common-map-0.0.1-prerelease.234.tgz",
|
"resolved": "https://repository.akkerweb.nl/repository/npm-group/@farmmaps/common-map/-/common-map-0.0.1-prerelease.241.tgz",
|
||||||
"integrity": "sha512-WXmWSgq1UF3rTuQV5avHzfOpOyLhbtNQTv7Bqtpn3kyEJDepfOe2u2uYHoQiA+j+S91XVqBkAL8SOC/rtUAVMg=="
|
"integrity": "sha512-Q9GnIbe0SjrJ97qCOQHJTquNeRNdPu5gIYR6gNPqMN8CaTLu6lGdON5nn7M5+TEMjPgGSuqpKlHpQQssIyqrXA=="
|
||||||
},
|
},
|
||||||
"@istanbuljs/schema": {
|
"@istanbuljs/schema": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
@ -2752,6 +2742,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@microsoft/signalr": {
|
||||||
|
"version": "3.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@microsoft/signalr/-/signalr-3.1.3.tgz",
|
||||||
|
"integrity": "sha512-jcjzvPDP3VbtmUoTDwgKEjaQ1m4FgSiS00zvybcF8UweAkdWUAYsaMXTISEk7E5nD0jrxyMMdSuPGgw9AcG46w==",
|
||||||
|
"requires": {
|
||||||
|
"eventsource": "^1.0.7",
|
||||||
|
"request": "^2.88.0",
|
||||||
|
"ws": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@ng-bootstrap/ng-bootstrap": {
|
"@ng-bootstrap/ng-bootstrap": {
|
||||||
"version": "6.0.2",
|
"version": "6.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-6.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-6.0.2.tgz",
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
"@angular/platform-browser": "~9.1.0",
|
"@angular/platform-browser": "~9.1.0",
|
||||||
"@angular/platform-browser-dynamic": "~9.1.0",
|
"@angular/platform-browser-dynamic": "~9.1.0",
|
||||||
"@angular/router": "~9.1.0",
|
"@angular/router": "~9.1.0",
|
||||||
"@aspnet/signalr": "^1.1.4",
|
"@microsoft/signalr": "^3.1.3",
|
||||||
"@farmmaps/common": ">=0.0.1-prerelease.234 <0.0.1",
|
"@farmmaps/common": ">=0.0.1-prerelease.236 <0.0.1",
|
||||||
"@farmmaps/common-map": ">=0.0.1-prerelease.234 <0.0.1",
|
"@farmmaps/common-map": ">=0.0.1-prerelease.236 <0.0.1",
|
||||||
"@ng-bootstrap/ng-bootstrap": "^6.0",
|
"@ng-bootstrap/ng-bootstrap": "^6.0",
|
||||||
"@ngrx/effects": "^9.0",
|
"@ngrx/effects": "^9.0",
|
||||||
"@ngrx/router-store": "^9.0",
|
"@ngrx/router-store": "^9.0",
|
||||||
|
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { IEventMessage } from '../models/event.message';
|
import { IEventMessage } from '../models/event.message';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { OAuthService } from 'angular-oauth2-oidc';
|
import { OAuthService } from 'angular-oauth2-oidc';
|
||||||
import { HubConnection, HubConnectionBuilder, LogLevel ,HttpTransportType} from '@aspnet/signalr';
|
import { HubConnection, HubConnectionBuilder, LogLevel ,HttpTransportType} from '@microsoft/signalr';
|
||||||
import { AppConfig } from "../shared/app.config";
|
import { AppConfig } from "../shared/app.config";
|
||||||
|
|
||||||
|
|
||||||
@ -23,15 +23,22 @@ export class EventService {
|
|||||||
// return oauthService.getAccessToken();
|
// return oauthService.getAccessToken();
|
||||||
// },
|
// },
|
||||||
skipNegotiation:true
|
skipNegotiation:true
|
||||||
}).configureLogging(LogLevel.Information).build();
|
}).withAutomaticReconnect().configureLogging(LogLevel.Information).build();
|
||||||
this._connection.on('event', eventMessage => {
|
this._connection.on('event', eventMessage => {
|
||||||
this.event.next(eventMessage);
|
this.event.next(eventMessage);
|
||||||
});
|
});
|
||||||
|
this._connection.onreconnected( event => {
|
||||||
|
this.Authenticate();
|
||||||
|
});
|
||||||
this._connection.start().then(() => {
|
this._connection.start().then(() => {
|
||||||
var accessToken = oauthService.getAccessToken();
|
this.Authenticate();
|
||||||
if (accessToken) {
|
|
||||||
this._connection.send('authenticate', oauthService.getAccessToken());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Authenticate() {
|
||||||
|
var accessToken = this.oauthService.getAccessToken();
|
||||||
|
if (accessToken) {
|
||||||
|
this._connection.send('authenticate', this.oauthService.getAccessToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user