@senior-gestao-empresarial/angular-components 4.22.0 → 4.22.2-7ecfc706-3270-4664-9d10-a6918ef49acd
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 +196 -108
- 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 -19
- package/esm2015/components/websocket/websocket.service.js +126 -92
- package/esm5/components/websocket/websocket.service.js +194 -108
- package/fesm2015/senior-gestao-empresarial-angular-components.js +125 -90
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +193 -106
- 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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/breadcrumb'), require('@angular/router'), require('rxjs'), require('rxjs/operators'), require('moment'), require('@seniorsistemas/angular-components'), require('@angular/common/http'), require('primeng/api'), require('@ngx-translate/core'), require('@seniorsistemas/platform-components'), require('@seniorsistemas/senior-platform-data'), require('@angular/forms'), require('js-cookie'), require('@stomp/stompjs'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@senior-gestao-empresarial/angular-components', ['exports', '@angular/core', '@angular/common', 'primeng/breadcrumb', '@angular/router', 'rxjs', 'rxjs/operators', 'moment', '@seniorsistemas/angular-components', '@angular/common/http', 'primeng/api', '@ngx-translate/core', '@seniorsistemas/platform-components', '@seniorsistemas/senior-platform-data', '@angular/forms', 'js-cookie', '@stomp/stompjs', '
|
|
4
|
-
(global = global || self, factory((global['senior-gestao-empresarial'] = global['senior-gestao-empresarial'] || {}, global['senior-gestao-empresarial']['angular-components'] = {}), global.ng.core, global.ng.common, global.breadcrumb, global.ng.router, global.rxjs, global.rxjs.operators, global.moment_, global.angularComponents, global.ng.common.http, global.api, global.core$1, global.platformComponents, global.seniorPlatformData, global.ng.forms, global.jsCookie, global.stompjs, global.
|
|
5
|
-
}(this, (function (exports, core, common, breadcrumb, router, rxjs, operators, moment_, angularComponents, http, api, core$1, platformComponents, seniorPlatformData, forms, jsCookie, stompjs,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/breadcrumb'), require('@angular/router'), require('rxjs'), require('rxjs/operators'), require('moment'), require('@seniorsistemas/angular-components'), require('@angular/common/http'), require('primeng/api'), require('@ngx-translate/core'), require('@seniorsistemas/platform-components'), require('@seniorsistemas/senior-platform-data'), require('@angular/forms'), require('js-cookie'), require('@stomp/stompjs'), require('sockjs-client')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@senior-gestao-empresarial/angular-components', ['exports', '@angular/core', '@angular/common', 'primeng/breadcrumb', '@angular/router', 'rxjs', 'rxjs/operators', 'moment', '@seniorsistemas/angular-components', '@angular/common/http', 'primeng/api', '@ngx-translate/core', '@seniorsistemas/platform-components', '@seniorsistemas/senior-platform-data', '@angular/forms', 'js-cookie', '@stomp/stompjs', 'sockjs-client'], factory) :
|
|
4
|
+
(global = global || self, factory((global['senior-gestao-empresarial'] = global['senior-gestao-empresarial'] || {}, global['senior-gestao-empresarial']['angular-components'] = {}), global.ng.core, global.ng.common, global.breadcrumb, global.ng.router, global.rxjs, global.rxjs.operators, global.moment_, global.angularComponents, global.ng.common.http, global.api, global.core$1, global.platformComponents, global.seniorPlatformData, global.ng.forms, global.jsCookie, global.stompjs, global.SockJS));
|
|
5
|
+
}(this, (function (exports, core, common, breadcrumb, router, rxjs, operators, moment_, angularComponents, http, api, core$1, platformComponents, seniorPlatformData, forms, jsCookie, stompjs, SockJS) { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
@@ -6609,26 +6609,24 @@
|
|
|
6609
6609
|
}());
|
|
6610
6610
|
|
|
6611
6611
|
var WebsocketService = /** @class */ (function () {
|
|
6612
|
-
function WebsocketService(
|
|
6613
|
-
this.cookieService = cookieService;
|
|
6614
|
-
this.baseUrl = null;
|
|
6615
|
-
this.username = null;
|
|
6612
|
+
function WebsocketService() {
|
|
6616
6613
|
this.focused = true;
|
|
6614
|
+
this.wasConnected = false;
|
|
6617
6615
|
this.connected = false;
|
|
6618
6616
|
this.isConnecting = false;
|
|
6619
|
-
this.stompSubscriptions = new Map();
|
|
6620
|
-
// private primitiveSubjects: Map<string, Subject<any>> = new Map<string, Subject<any>>();
|
|
6621
6617
|
this.primitiveManagers = new Map();
|
|
6622
|
-
this.disconnectSubject = new rxjs.Subject();
|
|
6623
6618
|
this.connect$ = new rxjs.Subject();
|
|
6619
|
+
this.disconnect$ = new rxjs.Subject();
|
|
6620
|
+
this.reconnect$ = new rxjs.Subject();
|
|
6621
|
+
this.error$ = new rxjs.Subject();
|
|
6624
6622
|
window.onfocus = this.onFocus;
|
|
6625
6623
|
window.onblur = this.onBlur;
|
|
6626
6624
|
this.connect();
|
|
6627
6625
|
}
|
|
6628
6626
|
WebsocketService_1 = WebsocketService;
|
|
6629
6627
|
/**
|
|
6630
|
-
* Observable
|
|
6631
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida
|
|
6628
|
+
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida.
|
|
6629
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida.
|
|
6632
6630
|
*/
|
|
6633
6631
|
WebsocketService.prototype.onConnect = function () {
|
|
6634
6632
|
var _this = this;
|
|
@@ -6640,67 +6638,69 @@
|
|
|
6640
6638
|
return this.connect$.asObservable();
|
|
6641
6639
|
};
|
|
6642
6640
|
/**
|
|
6643
|
-
* Observable
|
|
6644
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão é
|
|
6641
|
+
* Observable responsável por emitir uma notificação quando a conexão é desconectada.
|
|
6642
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão é desconectada.
|
|
6645
6643
|
*/
|
|
6646
6644
|
WebsocketService.prototype.onDisconnect = function () {
|
|
6647
|
-
return this.
|
|
6645
|
+
return this.disconnect$.asObservable();
|
|
6646
|
+
};
|
|
6647
|
+
/**
|
|
6648
|
+
* Observable responsável por emitir uma notificação quando a conexão é reconectada.
|
|
6649
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão é reconectada.
|
|
6650
|
+
*/
|
|
6651
|
+
WebsocketService.prototype.onReconnect = function () {
|
|
6652
|
+
return this.reconnect$.asObservable();
|
|
6653
|
+
};
|
|
6654
|
+
/**
|
|
6655
|
+
* Observable responsável por emitir uma notificação quando ocorre algum erro.
|
|
6656
|
+
* @return Um `Observable<FrameImpl>` que emite uma notificação quando ocorre algum erro.
|
|
6657
|
+
*/
|
|
6658
|
+
WebsocketService.prototype.onError = function () {
|
|
6659
|
+
return this.error$.asObservable();
|
|
6648
6660
|
};
|
|
6649
6661
|
/**
|
|
6650
6662
|
* Observable responsável por emitir uma notificação quando um evento é publicado.
|
|
6651
6663
|
* @typeParam `<T>` Tipo do objeto que o retorno do `observable` vai devolver.
|
|
6652
|
-
* @param domain Dominio da
|
|
6664
|
+
* @param domain Dominio da primitiva.
|
|
6653
6665
|
* @param service Service da primitiva.
|
|
6654
6666
|
* @param primitive Primitiva que será "observada" pelo client.
|
|
6655
|
-
* @param identifierPath Caminho até a propriedade considerada o
|
|
6667
|
+
* @param identifierPath Caminho até a propriedade considerada o identificador do registro.
|
|
6656
6668
|
* @return Um `observable` que emite notificações toda vez que o respectivo evento é publicado no sistema.
|
|
6657
6669
|
*/
|
|
6658
6670
|
WebsocketService.prototype.onEvent = function (domain, service, primitive, identifierPath) {
|
|
6659
6671
|
var _this = this;
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
return primitiveManager.subject.asObservable();
|
|
6672
|
+
if (this.primitiveManagers.has(primitive)) {
|
|
6673
|
+
return this.primitiveManagers.get(primitive).subject.asObservable();
|
|
6663
6674
|
}
|
|
6664
|
-
primitiveManager = {
|
|
6675
|
+
var primitiveManager = {
|
|
6676
|
+
domain: domain,
|
|
6677
|
+
service: service,
|
|
6678
|
+
primitive: primitive,
|
|
6679
|
+
stompSubscriptions: [],
|
|
6665
6680
|
subject: new rxjs.Subject(),
|
|
6666
6681
|
identifierPath: identifierPath,
|
|
6667
6682
|
publishedEvents: [],
|
|
6668
6683
|
};
|
|
6684
|
+
this.primitiveManagers.set(primitive, primitiveManager);
|
|
6669
6685
|
if (this.isConnected()) {
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
var stompSubscription = this._stompClient.subscribe(url, function (message) {
|
|
6673
|
-
var event = JSON.parse(message.body || "{}");
|
|
6674
|
-
_this.addPublishedEvent(primitiveManager, event);
|
|
6675
|
-
primitiveManager.subject.next(event);
|
|
6676
|
-
});
|
|
6677
|
-
this.stompSubscriptions.set(primitive, stompSubscription);
|
|
6678
|
-
return primitiveManager.subject.asObservable();
|
|
6686
|
+
this.createStompSubscriptions(primitiveManager);
|
|
6687
|
+
return primitiveManager.subject.pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitive); }));
|
|
6679
6688
|
}
|
|
6680
6689
|
else {
|
|
6681
6690
|
if (!this.isConnecting) {
|
|
6682
6691
|
this.connect();
|
|
6683
6692
|
}
|
|
6684
|
-
this.
|
|
6685
|
-
.
|
|
6686
|
-
.subscribe(function () {
|
|
6687
|
-
var url = _this.getSubscriptionUserUrl(domain, service, primitive);
|
|
6688
|
-
_this.primitiveManagers.set(primitive, primitiveManager);
|
|
6689
|
-
var stompSubscription = _this._stompClient.subscribe(url, function (message) {
|
|
6690
|
-
var event = JSON.parse(message.body || "{}");
|
|
6691
|
-
_this.addPublishedEvent(primitiveManager, event);
|
|
6692
|
-
primitiveManager.subject.next(event);
|
|
6693
|
-
});
|
|
6694
|
-
_this.stompSubscriptions.set(primitive, stompSubscription);
|
|
6693
|
+
this.connect$.pipe(operators.first()).subscribe(function () {
|
|
6694
|
+
_this.createStompSubscriptions(primitiveManager);
|
|
6695
6695
|
});
|
|
6696
|
-
return primitiveManager.subject.
|
|
6696
|
+
return primitiveManager.subject.pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitive); }));
|
|
6697
6697
|
}
|
|
6698
6698
|
};
|
|
6699
6699
|
/**
|
|
6700
|
-
* Retorna todos os eventos ouvidos
|
|
6700
|
+
* Retorna todos os eventos ouvidos pela primitiva com os respectivos identificadores.
|
|
6701
6701
|
* @typeParam `<T>` Tipo do evento retornado pela primitiva.
|
|
6702
6702
|
* @param primitive Primitiva que será "observada" pelo client.
|
|
6703
|
-
* @param identifiers Array com os
|
|
6703
|
+
* @param identifiers Array com os identificadores interessados.
|
|
6704
6704
|
* @return Array contendo o último evento recebido de cada identificador fornecido.
|
|
6705
6705
|
*/
|
|
6706
6706
|
WebsocketService.prototype.getPublishedEvents = function (primitive, identifiers) {
|
|
@@ -6732,9 +6732,7 @@
|
|
|
6732
6732
|
WebsocketService.prototype.addPublishedEvent = function (primitiveManager, event) {
|
|
6733
6733
|
var _this = this;
|
|
6734
6734
|
var identifier = this.getIdentifierFromEvent(primitiveManager.identifierPath, event);
|
|
6735
|
-
var eventIndex = primitiveManager.publishedEvents.findIndex(function (x) {
|
|
6736
|
-
return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier;
|
|
6737
|
-
});
|
|
6735
|
+
var eventIndex = primitiveManager.publishedEvents.findIndex(function (x) { return _this.getIdentifierFromEvent(primitiveManager.identifierPath, x) === identifier; });
|
|
6738
6736
|
if (eventIndex !== -1) {
|
|
6739
6737
|
primitiveManager.publishedEvents[eventIndex] = __assign(__assign({}, primitiveManager.publishedEvents[eventIndex]), event);
|
|
6740
6738
|
}
|
|
@@ -6742,6 +6740,13 @@
|
|
|
6742
6740
|
primitiveManager.publishedEvents.push(event);
|
|
6743
6741
|
}
|
|
6744
6742
|
};
|
|
6743
|
+
WebsocketService.prototype.createStompSubscriptions = function (primitiveManager) {
|
|
6744
|
+
var withTokenUrl = this.getSubscriptionUrlWithToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6745
|
+
var stompSubscriptionWithToken = this.createStompSubscription(withTokenUrl, primitiveManager);
|
|
6746
|
+
var withoutTokenUrl = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
6747
|
+
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
6748
|
+
primitiveManager.stompSubscriptions = [stompSubscriptionWithToken, stompSubscriptionWithoutToken];
|
|
6749
|
+
};
|
|
6745
6750
|
WebsocketService.prototype.getIdentifierFromEvent = function (identifierPath, event) {
|
|
6746
6751
|
var e_2, _a;
|
|
6747
6752
|
var properties = identifierPath.split(".");
|
|
@@ -6765,15 +6770,22 @@
|
|
|
6765
6770
|
var _this = this;
|
|
6766
6771
|
this.createStompClient();
|
|
6767
6772
|
this.isConnecting = true;
|
|
6773
|
+
this._stompClient.activate();
|
|
6768
6774
|
this._stompClient.connect({}, function () {
|
|
6769
|
-
_this.setConnected(true);
|
|
6770
|
-
// console.log('setou false isConnecting');
|
|
6771
6775
|
_this.isConnecting = false;
|
|
6772
|
-
|
|
6773
|
-
_this.
|
|
6774
|
-
|
|
6776
|
+
_this.setConnected(true);
|
|
6777
|
+
if (_this.wasConnected) {
|
|
6778
|
+
_this.reconnectPrimitives();
|
|
6779
|
+
_this.reconnect$.next();
|
|
6780
|
+
}
|
|
6781
|
+
else {
|
|
6782
|
+
_this.wasConnected = true;
|
|
6783
|
+
_this.publishOnConnect();
|
|
6784
|
+
}
|
|
6785
|
+
}, function (error) {
|
|
6775
6786
|
_this.setConnected(false);
|
|
6776
|
-
|
|
6787
|
+
_this.error$.next(error);
|
|
6788
|
+
_this.reconnect();
|
|
6777
6789
|
});
|
|
6778
6790
|
};
|
|
6779
6791
|
WebsocketService.prototype.publishOnConnect = function () {
|
|
@@ -6787,46 +6799,54 @@
|
|
|
6787
6799
|
this.focused = false;
|
|
6788
6800
|
};
|
|
6789
6801
|
WebsocketService.prototype.disconnect = function () {
|
|
6790
|
-
var e_3, _a, e_4, _b;
|
|
6791
|
-
var observersCount =
|
|
6802
|
+
var e_3, _a, e_4, _b, e_5, _c;
|
|
6803
|
+
var observersCount = this.getObserversCount();
|
|
6804
|
+
if (observersCount > 0)
|
|
6805
|
+
return;
|
|
6792
6806
|
try {
|
|
6793
|
-
for (var
|
|
6794
|
-
var primitiveManager =
|
|
6795
|
-
|
|
6807
|
+
for (var _d = __values(this.primitiveManagers.values()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
6808
|
+
var primitiveManager = _e.value;
|
|
6809
|
+
try {
|
|
6810
|
+
for (var _f = (e_4 = void 0, __values(primitiveManager.stompSubscriptions)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
6811
|
+
var stompSubscription = _g.value;
|
|
6812
|
+
stompSubscription.unsubscribe();
|
|
6813
|
+
}
|
|
6814
|
+
}
|
|
6815
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
6816
|
+
finally {
|
|
6817
|
+
try {
|
|
6818
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
6819
|
+
}
|
|
6820
|
+
finally { if (e_4) throw e_4.error; }
|
|
6821
|
+
}
|
|
6796
6822
|
}
|
|
6797
6823
|
}
|
|
6798
6824
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
6799
6825
|
finally {
|
|
6800
6826
|
try {
|
|
6801
|
-
if (
|
|
6827
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
6802
6828
|
}
|
|
6803
6829
|
finally { if (e_3) throw e_3.error; }
|
|
6804
6830
|
}
|
|
6805
|
-
|
|
6806
|
-
this.
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
try {
|
|
6810
|
-
for (var _e = __values(this.primitiveManagers.values()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
6811
|
-
var primitiveManager = _f.value;
|
|
6812
|
-
primitiveManager.subject.complete();
|
|
6813
|
-
}
|
|
6831
|
+
try {
|
|
6832
|
+
for (var _h = __values(this.primitiveManagers.values()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
6833
|
+
var primitiveManager = _j.value;
|
|
6834
|
+
primitiveManager.subject.complete();
|
|
6814
6835
|
}
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
finally { if (e_4) throw e_4.error; }
|
|
6836
|
+
}
|
|
6837
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
6838
|
+
finally {
|
|
6839
|
+
try {
|
|
6840
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
6821
6841
|
}
|
|
6822
|
-
|
|
6823
|
-
this.primitiveManagers.clear();
|
|
6824
|
-
this._stompClient.disconnect();
|
|
6825
|
-
this._stompClient.deactivate();
|
|
6826
|
-
this.setConnected(false);
|
|
6827
|
-
this.isConnecting = false;
|
|
6828
|
-
this.disconnectSubject.next();
|
|
6842
|
+
finally { if (e_5) throw e_5.error; }
|
|
6829
6843
|
}
|
|
6844
|
+
this.primitiveManagers.clear();
|
|
6845
|
+
this._stompClient.disconnect();
|
|
6846
|
+
this._stompClient.deactivate();
|
|
6847
|
+
this.setConnected(false);
|
|
6848
|
+
this.isConnecting = false;
|
|
6849
|
+
this.disconnect$.next();
|
|
6830
6850
|
};
|
|
6831
6851
|
WebsocketService.prototype.isConnected = function () {
|
|
6832
6852
|
return this.connected;
|
|
@@ -6834,56 +6854,124 @@
|
|
|
6834
6854
|
WebsocketService.prototype.setConnected = function (connected) {
|
|
6835
6855
|
this.connected = connected;
|
|
6836
6856
|
};
|
|
6837
|
-
WebsocketService.prototype.
|
|
6857
|
+
WebsocketService.prototype.getSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
6838
6858
|
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6839
6859
|
var token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
|
|
6840
6860
|
return "/topic/" + tenant + "/" + token + "/" + domain + "/" + service + "/" + primitive;
|
|
6841
6861
|
};
|
|
6862
|
+
WebsocketService.prototype.getSubscriptionUrlWithoutToken = function (domain, service, primitive) {
|
|
6863
|
+
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
6864
|
+
return "/topic/" + tenant + "/" + domain + "/" + service + "/" + primitive;
|
|
6865
|
+
};
|
|
6866
|
+
WebsocketService.prototype.createStompSubscription = function (destination, primitiveManager) {
|
|
6867
|
+
var _this = this;
|
|
6868
|
+
return this._stompClient.subscribe(destination, function (message) {
|
|
6869
|
+
var event = JSON.parse(message.body || "{}");
|
|
6870
|
+
_this.addPublishedEvent(primitiveManager, event);
|
|
6871
|
+
primitiveManager.subject.next(event);
|
|
6872
|
+
});
|
|
6873
|
+
};
|
|
6842
6874
|
WebsocketService.prototype.createStompClient = function () {
|
|
6843
6875
|
var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
6844
6876
|
this._stompClient = stompjs.Stomp.over(ws);
|
|
6877
|
+
// this._stompClient.debug = (str) => console.log(new Date().toISOString(), str);
|
|
6845
6878
|
this._stompClient.debug = function () { }; // Para remover os logs.
|
|
6846
6879
|
};
|
|
6847
|
-
WebsocketService.prototype.
|
|
6848
|
-
return this.cookieService.get("com.senior.base.url");
|
|
6849
|
-
};
|
|
6850
|
-
WebsocketService.prototype.getUserName = function () {
|
|
6851
|
-
var token = this.cookieService.get("com.senior.token");
|
|
6852
|
-
return token && JSON.parse(token).username;
|
|
6853
|
-
};
|
|
6854
|
-
WebsocketService.prototype.reconnectWebSocket = function () {
|
|
6880
|
+
WebsocketService.prototype.reconnect = function () {
|
|
6855
6881
|
var _this = this;
|
|
6856
|
-
this.
|
|
6857
|
-
|
|
6858
|
-
if (this.baseUrl !== null && baseUrl != this.baseUrl) {
|
|
6859
|
-
// //console.log('ws disconnected: base url changed', this.baseUrl, ' -> ', baseUrl || 'null');
|
|
6860
|
-
return;
|
|
6861
|
-
}
|
|
6862
|
-
var username = this.getUserName();
|
|
6863
|
-
if (this.username !== null && username != this.username) {
|
|
6864
|
-
// //console.log('ws disconnected: username changed', this.username, ' -> ', username || 'null');
|
|
6865
|
-
return;
|
|
6866
|
-
}
|
|
6882
|
+
if (this.connected)
|
|
6883
|
+
this._stompClient.disconnect();
|
|
6867
6884
|
setTimeout(function () {
|
|
6885
|
+
if (_this.getObserversCount() === 0)
|
|
6886
|
+
return;
|
|
6868
6887
|
if (_this.focused) {
|
|
6869
6888
|
_this.connect();
|
|
6870
6889
|
}
|
|
6871
6890
|
else {
|
|
6872
|
-
_this.
|
|
6891
|
+
_this.reconnect();
|
|
6873
6892
|
}
|
|
6874
6893
|
}, WebsocketService_1.RECONNECT_TIMER);
|
|
6875
6894
|
};
|
|
6895
|
+
WebsocketService.prototype.reconnectPrimitives = function () {
|
|
6896
|
+
var e_6, _a, e_7, _b;
|
|
6897
|
+
try {
|
|
6898
|
+
for (var _c = __values(this.primitiveManagers.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
6899
|
+
var primitiveManager = _d.value;
|
|
6900
|
+
try {
|
|
6901
|
+
for (var _e = (e_7 = void 0, __values(primitiveManager.stompSubscriptions)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
6902
|
+
var stompSubscription = _f.value;
|
|
6903
|
+
stompSubscription.unsubscribe();
|
|
6904
|
+
}
|
|
6905
|
+
}
|
|
6906
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
6907
|
+
finally {
|
|
6908
|
+
try {
|
|
6909
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
6910
|
+
}
|
|
6911
|
+
finally { if (e_7) throw e_7.error; }
|
|
6912
|
+
}
|
|
6913
|
+
this.createStompSubscriptions(primitiveManager);
|
|
6914
|
+
}
|
|
6915
|
+
}
|
|
6916
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
6917
|
+
finally {
|
|
6918
|
+
try {
|
|
6919
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
6920
|
+
}
|
|
6921
|
+
finally { if (e_6) throw e_6.error; }
|
|
6922
|
+
}
|
|
6923
|
+
};
|
|
6924
|
+
WebsocketService.prototype.getObserversCount = function () {
|
|
6925
|
+
var e_8, _a;
|
|
6926
|
+
var observersCount = 0;
|
|
6927
|
+
try {
|
|
6928
|
+
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6929
|
+
var primitiveManager = _c.value;
|
|
6930
|
+
observersCount += primitiveManager.subject.observers.length;
|
|
6931
|
+
}
|
|
6932
|
+
}
|
|
6933
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
6934
|
+
finally {
|
|
6935
|
+
try {
|
|
6936
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6937
|
+
}
|
|
6938
|
+
finally { if (e_8) throw e_8.error; }
|
|
6939
|
+
}
|
|
6940
|
+
return observersCount;
|
|
6941
|
+
};
|
|
6942
|
+
WebsocketService.prototype.disconnectPrimitiveOnFinalize = function (primitive) {
|
|
6943
|
+
var e_9, _a;
|
|
6944
|
+
var primitiveManager = this.primitiveManagers.get(primitive);
|
|
6945
|
+
if (!primitiveManager)
|
|
6946
|
+
return;
|
|
6947
|
+
// @IMPORTANT: Replace .observers.length with .observed in rxjs 7.0+
|
|
6948
|
+
var hasObservers = !(primitiveManager.subject.observers.length === 1);
|
|
6949
|
+
if (hasObservers)
|
|
6950
|
+
return;
|
|
6951
|
+
try {
|
|
6952
|
+
for (var _b = __values(primitiveManager.stompSubscriptions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
6953
|
+
var stompSubscription = _c.value;
|
|
6954
|
+
stompSubscription.unsubscribe();
|
|
6955
|
+
}
|
|
6956
|
+
}
|
|
6957
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
6958
|
+
finally {
|
|
6959
|
+
try {
|
|
6960
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
6961
|
+
}
|
|
6962
|
+
finally { if (e_9) throw e_9.error; }
|
|
6963
|
+
}
|
|
6964
|
+
this.primitiveManagers.delete(primitive);
|
|
6965
|
+
this.disconnect();
|
|
6966
|
+
};
|
|
6876
6967
|
var WebsocketService_1;
|
|
6877
6968
|
WebsocketService.RECONNECT_TIMER = 3000;
|
|
6878
|
-
WebsocketService.CONNECTION_TIMEOUT =
|
|
6969
|
+
WebsocketService.CONNECTION_TIMEOUT = 15000;
|
|
6879
6970
|
WebsocketService.BASE_URL_COOKIE = "com.senior.base.url";
|
|
6880
6971
|
WebsocketService.TOKEN_COOKIE = "com.senior.token";
|
|
6881
6972
|
WebsocketService.TOKEN = JSON.parse(jsCookie.get(WebsocketService_1.TOKEN_COOKIE) || "{}");
|
|
6882
6973
|
WebsocketService.WEBSOCKET_URL = jsCookie.get(WebsocketService_1.BASE_URL_COOKIE) + "/websocket/";
|
|
6883
|
-
WebsocketService
|
|
6884
|
-
{ type: ngxCookieService.CookieService }
|
|
6885
|
-
]; };
|
|
6886
|
-
WebsocketService.ɵprov = core.ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(core.ɵɵinject(ngxCookieService.CookieService)); }, token: WebsocketService, providedIn: "root" });
|
|
6974
|
+
WebsocketService.ɵprov = core.ɵɵdefineInjectable({ factory: function WebsocketService_Factory() { return new WebsocketService(); }, token: WebsocketService, providedIn: "root" });
|
|
6887
6975
|
WebsocketService = WebsocketService_1 = __decorate([
|
|
6888
6976
|
core.Injectable({
|
|
6889
6977
|
providedIn: "root",
|