@senior-gestao-empresarial/angular-components 4.22.0 → 4.22.2-7c0b6b2c-1273-4faf-bd8a-91d677cec9bd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/senior-gestao-empresarial-angular-components.umd.js +199 -114
- package/bundles/senior-gestao-empresarial-angular-components.umd.js.map +1 -1
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js +2 -2
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js.map +1 -1
- package/components/websocket/websocket.service.d.ts +32 -20
- package/esm2015/components/websocket/websocket.service.js +129 -98
- package/esm5/components/websocket/websocket.service.js +197 -114
- package/fesm2015/senior-gestao-empresarial-angular-components.js +128 -96
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +196 -112
- package/fesm5/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/senior-gestao-empresarial-angular-components.metadata.json +1 -1
|
@@ -4,7 +4,7 @@ import { CommonModule } from '@angular/common';
|
|
|
4
4
|
import { BreadcrumbModule as BreadcrumbModule$1 } from 'primeng/breadcrumb';
|
|
5
5
|
import { NavigationEnd, PRIMARY_OUTLET, ActivatedRoute, Router, RouterModule } from '@angular/router';
|
|
6
6
|
import { Subject, throwError, interval, of, ReplaySubject } from 'rxjs';
|
|
7
|
-
import { takeUntil, filter, catchError, map, takeWhile, switchMap, take } from 'rxjs/operators';
|
|
7
|
+
import { takeUntil, filter, catchError, map, takeWhile, switchMap, first, finalize, take } from 'rxjs/operators';
|
|
8
8
|
import * as moment_ from 'moment';
|
|
9
9
|
import { FormField, FieldType } from '@seniorsistemas/angular-components';
|
|
10
10
|
import { HttpParams, HttpClient } from '@angular/common/http';
|
|
@@ -15,7 +15,6 @@ import { user } from '@seniorsistemas/senior-platform-data';
|
|
|
15
15
|
import { FormControl, FormGroup } from '@angular/forms';
|
|
16
16
|
import { get } from 'js-cookie';
|
|
17
17
|
import { Stomp } from '@stomp/stompjs';
|
|
18
|
-
import { CookieService } from 'ngx-cookie-service';
|
|
19
18
|
import * as SockJS from 'sockjs-client';
|
|
20
19
|
|
|
21
20
|
var BreadcrumbComponent = /** @class */ (function () {
|
|
@@ -6404,98 +6403,98 @@ var NpsService = /** @class */ (function () {
|
|
|
6404
6403
|
}());
|
|
6405
6404
|
|
|
6406
6405
|
var WebsocketService = /** @class */ (function () {
|
|
6407
|
-
function WebsocketService(
|
|
6408
|
-
this.cookieService = cookieService;
|
|
6409
|
-
this.baseUrl = null;
|
|
6410
|
-
this.username = null;
|
|
6406
|
+
function WebsocketService() {
|
|
6411
6407
|
this.focused = true;
|
|
6408
|
+
this.wasConnected = false;
|
|
6412
6409
|
this.connected = false;
|
|
6413
6410
|
this.isConnecting = false;
|
|
6414
|
-
this.stompSubscriptions = new Map();
|
|
6415
|
-
// private primitiveSubjects: Map<string, Subject<any>> = new Map<string, Subject<any>>();
|
|
6416
6411
|
this.primitiveManagers = new Map();
|
|
6417
|
-
this.disconnectSubject = new Subject();
|
|
6418
6412
|
this.connect$ = new Subject();
|
|
6413
|
+
this.disconnect$ = new Subject();
|
|
6414
|
+
this.reconnect$ = new Subject();
|
|
6415
|
+
this.error$ = new Subject();
|
|
6419
6416
|
window.onfocus = this.onFocus;
|
|
6420
6417
|
window.onblur = this.onBlur;
|
|
6421
6418
|
this.connect();
|
|
6422
6419
|
}
|
|
6423
6420
|
WebsocketService_1 = WebsocketService;
|
|
6424
6421
|
/**
|
|
6425
|
-
* Observable
|
|
6426
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida
|
|
6422
|
+
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida.
|
|
6423
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida.
|
|
6427
6424
|
*/
|
|
6428
6425
|
WebsocketService.prototype.onConnect = function () {
|
|
6429
6426
|
var _this = this;
|
|
6430
6427
|
setTimeout(function () {
|
|
6431
6428
|
if (_this.isConnected()) {
|
|
6432
|
-
_this.
|
|
6429
|
+
_this.connect$.next();
|
|
6433
6430
|
}
|
|
6434
6431
|
}, 0);
|
|
6435
|
-
return this.connect$.
|
|
6432
|
+
return this.connect$.pipe(first());
|
|
6436
6433
|
};
|
|
6437
6434
|
/**
|
|
6438
|
-
* Observable
|
|
6439
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é
|
|
6435
|
+
* Observable responsável por emitir uma notificação quando a conexão é desconectada.
|
|
6436
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão é desconectada.
|
|
6440
6437
|
*/
|
|
6441
6438
|
WebsocketService.prototype.onDisconnect = function () {
|
|
6442
|
-
return this.
|
|
6439
|
+
return this.disconnect$.asObservable();
|
|
6440
|
+
};
|
|
6441
|
+
/**
|
|
6442
|
+
* Observable responsável por emitir uma notificação quando a conexão é reconectada.
|
|
6443
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão é reconectada.
|
|
6444
|
+
*/
|
|
6445
|
+
WebsocketService.prototype.onReconnect = function () {
|
|
6446
|
+
return this.reconnect$.asObservable();
|
|
6447
|
+
};
|
|
6448
|
+
/**
|
|
6449
|
+
* Observable responsável por emitir uma notificação quando ocorre algum erro.
|
|
6450
|
+
* @return Um `Observable<FrameImpl>` que emite uma notificação quando ocorre algum erro.
|
|
6451
|
+
*/
|
|
6452
|
+
WebsocketService.prototype.onError = function () {
|
|
6453
|
+
return this.error$.asObservable();
|
|
6443
6454
|
};
|
|
6444
6455
|
/**
|
|
6445
6456
|
* Observable responsável por emitir uma notificação quando um evento é publicado.
|
|
6446
6457
|
* @typeParam `<T>` Tipo do objeto que o retorno do `observable` vai devolver.
|
|
6447
|
-
* @param domain Dominio da
|
|
6458
|
+
* @param domain Dominio da primitiva.
|
|
6448
6459
|
* @param service Service da primitiva.
|
|
6449
6460
|
* @param primitive Primitiva que será "observada" pelo client.
|
|
6450
|
-
* @param identifierPath Caminho até a propriedade considerada o
|
|
6461
|
+
* @param identifierPath Caminho até a propriedade considerada o identificador do registro.
|
|
6451
6462
|
* @return Um `observable` que emite notificações toda vez que o respectivo evento é publicado no sistema.
|
|
6452
6463
|
*/
|
|
6453
6464
|
WebsocketService.prototype.onEvent = function (domain, service, primitive, identifierPath) {
|
|
6454
6465
|
var _this = this;
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
return primitiveManager.subject.asObservable();
|
|
6466
|
+
if (this.primitiveManagers.has(primitive)) {
|
|
6467
|
+
return this.primitiveManagers.get(primitive).subject.asObservable();
|
|
6458
6468
|
}
|
|
6459
|
-
primitiveManager = {
|
|
6469
|
+
var primitiveManager = {
|
|
6470
|
+
domain: domain,
|
|
6471
|
+
service: service,
|
|
6472
|
+
primitive: primitive,
|
|
6473
|
+
stompSubscriptions: [],
|
|
6460
6474
|
subject: new Subject(),
|
|
6461
6475
|
identifierPath: identifierPath,
|
|
6462
6476
|
publishedEvents: [],
|
|
6463
6477
|
};
|
|
6478
|
+
this.primitiveManagers.set(primitive, primitiveManager);
|
|
6464
6479
|
if (this.isConnected()) {
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
var stompSubscription = this._stompClient.subscribe(url, function (message) {
|
|
6468
|
-
var event = JSON.parse(message.body || "{}");
|
|
6469
|
-
_this.addPublishedEvent(primitiveManager, event);
|
|
6470
|
-
primitiveManager.subject.next(event);
|
|
6471
|
-
});
|
|
6472
|
-
this.stompSubscriptions.set(primitive, stompSubscription);
|
|
6473
|
-
return primitiveManager.subject.asObservable();
|
|
6480
|
+
this.createStompSubscriptions(primitiveManager);
|
|
6481
|
+
return primitiveManager.subject.pipe(finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitive); }));
|
|
6474
6482
|
}
|
|
6475
6483
|
else {
|
|
6476
6484
|
if (!this.isConnecting) {
|
|
6477
6485
|
this.connect();
|
|
6478
6486
|
}
|
|
6479
|
-
this.
|
|
6480
|
-
.
|
|
6481
|
-
.subscribe(function () {
|
|
6482
|
-
var url = _this.getSubscriptionUserUrl(domain, service, primitive);
|
|
6483
|
-
_this.primitiveManagers.set(primitive, primitiveManager);
|
|
6484
|
-
var stompSubscription = _this._stompClient.subscribe(url, function (message) {
|
|
6485
|
-
var event = JSON.parse(message.body || "{}");
|
|
6486
|
-
_this.addPublishedEvent(primitiveManager, event);
|
|
6487
|
-
primitiveManager.subject.next(event);
|
|
6488
|
-
});
|
|
6489
|
-
_this.stompSubscriptions.set(primitive, stompSubscription);
|
|
6487
|
+
this.connect$.pipe(first()).subscribe(function () {
|
|
6488
|
+
_this.createStompSubscriptions(primitiveManager);
|
|
6490
6489
|
});
|
|
6491
|
-
return primitiveManager.subject.
|
|
6490
|
+
return primitiveManager.subject.pipe(finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitive); }));
|
|
6492
6491
|
}
|
|
6493
6492
|
};
|
|
6494
6493
|
/**
|
|
6495
|
-
* Retorna todos os eventos ouvidos
|
|
6494
|
+
* Retorna todos os eventos ouvidos pela primitiva com os respectivos identificadores.
|
|
6496
6495
|
* @typeParam `<T>` Tipo do evento retornado pela primitiva.
|
|
6497
6496
|
* @param primitive Primitiva que será "observada" pelo client.
|
|
6498
|
-
* @param identifiers Array com os
|
|
6497
|
+
* @param identifiers Array com os identificadores interessados.
|
|
6499
6498
|
* @return Array contendo o último evento recebido de cada identificador fornecido.
|
|
6500
6499
|
*/
|
|
6501
6500
|
WebsocketService.prototype.getPublishedEvents = function (primitive, identifiers) {
|
|
@@ -6527,9 +6526,7 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6527
6526
|
WebsocketService.prototype.addPublishedEvent = function (primitiveManager, event) {
|
|
6528
6527
|
var _this = this;
|
|
6529
6528
|
var identifier = this.getIdentifierFromEvent(primitiveManager.identifierPath, event);
|
|
6530
|
-
var eventIndex = primitiveManager.publishedEvents.findIndex(function (x) {
|
|
6531
|
-
return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier;
|
|
6532
|
-
});
|
|
6529
|
+
var eventIndex = primitiveManager.publishedEvents.findIndex(function (x) { return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier; });
|
|
6533
6530
|
if (eventIndex !== -1) {
|
|
6534
6531
|
primitiveManager.publishedEvents[eventIndex] = __assign(__assign({}, primitiveManager.publishedEvents[eventIndex]), event);
|
|
6535
6532
|
}
|
|
@@ -6537,6 +6534,13 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6537
6534
|
primitiveManager.publishedEvents.push(event);
|
|
6538
6535
|
}
|
|
6539
6536
|
};
|
|
6537
|
+
WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
|
|
6538
|
+
var withTokenUrl = this.getSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6539
|
+
var stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
6540
|
+
var withoutTokenUrl = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6541
|
+
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
6542
|
+
primitiveManager.stompSubscriptions = [stompSubscriptionWithToken, stompSubscriptionWithoutToken];
|
|
6543
|
+
};
|
|
6540
6544
|
WebsocketService.prototype.getIdentifierFromEvent = function (identifierPath, event) {
|
|
6541
6545
|
var e_2, _a;
|
|
6542
6546
|
var properties = identifierPath.split(".");
|
|
@@ -6560,21 +6564,24 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6560
6564
|
var _this = this;
|
|
6561
6565
|
this.createStompClient();
|
|
6562
6566
|
this.isConnecting = true;
|
|
6567
|
+
this._stompClient.activate();
|
|
6563
6568
|
this._stompClient.connect({}, function () {
|
|
6564
|
-
_this.setConnected(true);
|
|
6565
|
-
// console.log('setou false isConnecting');
|
|
6566
6569
|
_this.isConnecting = false;
|
|
6567
|
-
|
|
6568
|
-
_this.
|
|
6569
|
-
|
|
6570
|
+
_this.setConnected(true);
|
|
6571
|
+
if (_this.wasConnected) {
|
|
6572
|
+
_this.reconnectPrimitives();
|
|
6573
|
+
_this.reconnect$.next();
|
|
6574
|
+
}
|
|
6575
|
+
else {
|
|
6576
|
+
_this.wasConnected = true;
|
|
6577
|
+
_this.connect$.next();
|
|
6578
|
+
}
|
|
6579
|
+
}, function (error) {
|
|
6570
6580
|
_this.setConnected(false);
|
|
6571
|
-
|
|
6581
|
+
_this.error$.next(error);
|
|
6582
|
+
_this.reconnect();
|
|
6572
6583
|
});
|
|
6573
6584
|
};
|
|
6574
|
-
WebsocketService.prototype.publishOnConnect = function () {
|
|
6575
|
-
this.connect$.next();
|
|
6576
|
-
this.connect$.observers = [];
|
|
6577
|
-
};
|
|
6578
6585
|
WebsocketService.prototype.onFocus = function () {
|
|
6579
6586
|
this.focused = true;
|
|
6580
6587
|
};
|
|
@@ -6582,46 +6589,55 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6582
6589
|
this.focused = false;
|
|
6583
6590
|
};
|
|
6584
6591
|
WebsocketService.prototype.disconnect = function () {
|
|
6585
|
-
var e_3, _a, e_4, _b;
|
|
6586
|
-
var observersCount =
|
|
6592
|
+
var e_3, _a, e_4, _b, e_5, _c;
|
|
6593
|
+
var observersCount = this.getObserversCount();
|
|
6594
|
+
if (observersCount > 0)
|
|
6595
|
+
return;
|
|
6587
6596
|
try {
|
|
6588
|
-
for (var
|
|
6589
|
-
var primitiveManager =
|
|
6590
|
-
|
|
6597
|
+
for (var _d = __values(this.primitiveManagers.values()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
6598
|
+
var primitiveManager = _e.value;
|
|
6599
|
+
try {
|
|
6600
|
+
for (var _f = (e_4 = void 0, __values(primitiveManager.stompSubscriptions)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
6601
|
+
var stompSubscription = _g.value;
|
|
6602
|
+
stompSubscription.unsubscribe();
|
|
6603
|
+
}
|
|
6604
|
+
}
|
|
6605
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
6606
|
+
finally {
|
|
6607
|
+
try {
|
|
6608
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
6609
|
+
}
|
|
6610
|
+
finally { if (e_4) throw e_4.error; }
|
|
6611
|
+
}
|
|
6591
6612
|
}
|
|
6592
6613
|
}
|
|
6593
6614
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
6594
6615
|
finally {
|
|
6595
6616
|
try {
|
|
6596
|
-
if (
|
|
6617
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
6597
6618
|
}
|
|
6598
6619
|
finally { if (e_3) throw e_3.error; }
|
|
6599
6620
|
}
|
|
6600
|
-
|
|
6601
|
-
this.
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
try {
|
|
6605
|
-
for (var _e = __values(this.primitiveManagers.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
6606
|
-
var primitiveManager = _f.value;
|
|
6607
|
-
primitiveManager.subject.complete();
|
|
6608
|
-
}
|
|
6621
|
+
try {
|
|
6622
|
+
for (var _h = __values(this.primitiveManagers.values()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
6623
|
+
var primitiveManager = _j.value;
|
|
6624
|
+
primitiveManager.subject.complete();
|
|
6609
6625
|
}
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
finally { if (e_4) throw e_4.error; }
|
|
6626
|
+
}
|
|
6627
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
6628
|
+
finally {
|
|
6629
|
+
try {
|
|
6630
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
6616
6631
|
}
|
|
6617
|
-
|
|
6618
|
-
this.primitiveManagers.clear();
|
|
6619
|
-
this._stompClient.disconnect();
|
|
6620
|
-
this._stompClient.deactivate();
|
|
6621
|
-
this.setConnected(false);
|
|
6622
|
-
this.isConnecting = false;
|
|
6623
|
-
this.disconnectSubject.next();
|
|
6632
|
+
finally { if (e_5) throw e_5.error; }
|
|
6624
6633
|
}
|
|
6634
|
+
this.primitiveManagers.clear();
|
|
6635
|
+
this._stompClient.disconnect();
|
|
6636
|
+
this._stompClient.deactivate();
|
|
6637
|
+
this.setConnected(false);
|
|
6638
|
+
this.isConnecting = false;
|
|
6639
|
+
this.wasConnected = false;
|
|
6640
|
+
this.disconnect$.next();
|
|
6625
6641
|
};
|
|
6626
6642
|
WebsocketService.prototype.isConnected = function () {
|
|
6627
6643
|
return this.connected;
|
|
@@ -6629,56 +6645,124 @@ var WebsocketService = /** @class */ (function () {
|
|
|
6629
6645
|
WebsocketService.prototype.setConnected = function (connected) {
|
|
6630
6646
|
this.connected = connected;
|
|
6631
6647
|
};
|
|
6632
|
-
WebsocketService.prototype.
|
|
6648
|
+
WebsocketService.prototype.getSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
6633
6649
|
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6634
6650
|
var token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
|
|
6635
6651
|
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
6636
6652
|
};
|
|
6653
|
+
WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
|
|
6654
|
+
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6655
|
+
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
6656
|
+
};
|
|
6657
|
+
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
6658
|
+
var _this = this;
|
|
6659
|
+
return this._stompClient.subscribe(destination, function (message) {
|
|
6660
|
+
var event = JSON.parse(message.body || "{}");
|
|
6661
|
+
_this.addPublishedEvent(primitiveManager, event);
|
|
6662
|
+
primitiveManager.subject.next(event);
|
|
6663
|
+
});
|
|
6664
|
+
};
|
|
6637
6665
|
WebsocketService.prototype.createStompClient = function () {
|
|
6638
6666
|
var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
6639
6667
|
this._stompClient = Stomp.over(ws);
|
|
6668
|
+
// this._stompClient.debug = (str) => console.log(new Date().toISOString(), str);
|
|
6640
6669
|
this._stompClient.debug = function () { }; // Para remover os logs.
|
|
6641
6670
|
};
|
|
6642
|
-
WebsocketService.prototype.
|
|
6643
|
-
return this.cookieService.get("com.senior.base.url");
|
|
6644
|
-
};
|
|
6645
|
-
WebsocketService.prototype.getUserName = function () {
|
|
6646
|
-
var token = this.cookieService.get("com.senior.token");
|
|
6647
|
-
return token && JSON.parse(token).username;
|
|
6648
|
-
};
|
|
6649
|
-
WebsocketService.prototype.reconnectWebSocket = function () {
|
|
6671
|
+
WebsocketService.prototype.reconnect = function () {
|
|
6650
6672
|
var _this = this;
|
|
6651
|
-
this.
|
|
6652
|
-
|
|
6653
|
-
if (this.baseUrl !== null && baseUrl != this.baseUrl) {
|
|
6654
|
-
// //console.log('ws disconnected: base url changed', this.baseUrl, ' -> ', baseUrl || 'null');
|
|
6655
|
-
return;
|
|
6656
|
-
}
|
|
6657
|
-
var username = this.getUserName();
|
|
6658
|
-
if (this.username !== null && username != this.username) {
|
|
6659
|
-
// //console.log('ws disconnected: username changed', this.username, ' -> ', username || 'null');
|
|
6660
|
-
return;
|
|
6661
|
-
}
|
|
6673
|
+
if (this.connected)
|
|
6674
|
+
this._stompClient.disconnect();
|
|
6662
6675
|
setTimeout(function () {
|
|
6676
|
+
if (_this.getObserversCount() === 0)
|
|
6677
|
+
return;
|
|
6663
6678
|
if (_this.focused) {
|
|
6664
6679
|
_this.connect();
|
|
6665
6680
|
}
|
|
6666
6681
|
else {
|
|
6667
|
-
_this.
|
|
6682
|
+
_this.reconnect();
|
|
6668
6683
|
}
|
|
6669
6684
|
}, WebsocketService_1.RECONNECT_TIMER);
|
|
6670
6685
|
};
|
|
6686
|
+
WebsocketService.prototype.reconnectPrimitives = function () {
|
|
6687
|
+
var e_6, _a, e_7, _b;
|
|
6688
|
+
try {
|
|
6689
|
+
for (var _c = __values(this.primitiveManagers.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
6690
|
+
var primitiveManager = _d.value;
|
|
6691
|
+
try {
|
|
6692
|
+
for (var _e = (e_7 = void 0, __values(primitiveManager.stompSubscriptions)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
6693
|
+
var stompSubscription = _f.value;
|
|
6694
|
+
stompSubscription.unsubscribe();
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
6698
|
+
finally {
|
|
6699
|
+
try {
|
|
6700
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
6701
|
+
}
|
|
6702
|
+
finally { if (e_7) throw e_7.error; }
|
|
6703
|
+
}
|
|
6704
|
+
this.createStompSubscriptions(primitiveManager);
|
|
6705
|
+
}
|
|
6706
|
+
}
|
|
6707
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
6708
|
+
finally {
|
|
6709
|
+
try {
|
|
6710
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
6711
|
+
}
|
|
6712
|
+
finally { if (e_6) throw e_6.error; }
|
|
6713
|
+
}
|
|
6714
|
+
};
|
|
6715
|
+
WebsocketService.prototype.getObserversCount = function () {
|
|
6716
|
+
var e_8, _a;
|
|
6717
|
+
var observersCount = 0;
|
|
6718
|
+
try {
|
|
6719
|
+
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6720
|
+
var primitiveManager = _c.value;
|
|
6721
|
+
observersCount += primitiveManager.subject.observers.length;
|
|
6722
|
+
}
|
|
6723
|
+
}
|
|
6724
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
6725
|
+
finally {
|
|
6726
|
+
try {
|
|
6727
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6728
|
+
}
|
|
6729
|
+
finally { if (e_8) throw e_8.error; }
|
|
6730
|
+
}
|
|
6731
|
+
return observersCount;
|
|
6732
|
+
};
|
|
6733
|
+
WebsocketService.prototype.disconnectPrimitiveOnFinalize = function (primitive) {
|
|
6734
|
+
var e_9, _a;
|
|
6735
|
+
var primitiveManager = this.primitiveManagers.get(primitive);
|
|
6736
|
+
if (!primitiveManager)
|
|
6737
|
+
return;
|
|
6738
|
+
// @IMPORTANT: Replace .observers.length with .observed in rxjs 7.0+
|
|
6739
|
+
var hasObservers = !(primitiveManager.subject.observers.length === 1);
|
|
6740
|
+
if (hasObservers)
|
|
6741
|
+
return;
|
|
6742
|
+
try {
|
|
6743
|
+
for (var _b = __values(primitiveManager.stompSubscriptions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6744
|
+
var stompSubscription = _c.value;
|
|
6745
|
+
stompSubscription.unsubscribe();
|
|
6746
|
+
}
|
|
6747
|
+
}
|
|
6748
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
6749
|
+
finally {
|
|
6750
|
+
try {
|
|
6751
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6752
|
+
}
|
|
6753
|
+
finally { if (e_9) throw e_9.error; }
|
|
6754
|
+
}
|
|
6755
|
+
this.primitiveManagers.delete(primitive);
|
|
6756
|
+
this.disconnect();
|
|
6757
|
+
};
|
|
6671
6758
|
var WebsocketService_1;
|
|
6672
6759
|
WebsocketService.RECONNECT_TIMER = 3000;
|
|
6673
|
-
WebsocketService.CONNECTION_TIMEOUT =
|
|
6760
|
+
WebsocketService.CONNECTION_TIMEOUT = 15000;
|
|
6674
6761
|
WebsocketService.BASE_URL_COOKIE = "com.senior.base.url";
|
|
6675
6762
|
WebsocketService.TOKEN_COOKIE = "com.senior.token";
|
|
6676
6763
|
WebsocketService.TOKEN = JSON.parse(get(WebsocketService_1.TOKEN_COOKIE) || "{}");
|
|
6677
6764
|
WebsocketService.WEBSOCKET_URL = get(WebsocketService_1.BASE_URL_COOKIE) + "/websocket/";
|
|
6678
|
-
WebsocketService
|
|
6679
|
-
{ type: CookieService }
|
|
6680
|
-
]; };
|
|
6681
|
-
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(ɵɵinject(CookieService)); }, token: WebsocketService, providedIn: "root" });
|
|
6765
|
+
WebsocketService.ɵprov = ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
|
|
6682
6766
|
WebsocketService = WebsocketService_1 = __decorate([
|
|
6683
6767
|
Injectable({
|
|
6684
6768
|
providedIn: "root",
|