@esfaenza/signalr-notifications 11.2.11 → 11.2.13
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/esfaenza-signalr-notifications.umd.js +28 -21
- package/bundles/esfaenza-signalr-notifications.umd.js.map +1 -1
- package/bundles/esfaenza-signalr-notifications.umd.min.js +1 -1
- package/bundles/esfaenza-signalr-notifications.umd.min.js.map +1 -1
- package/esfaenza-signalr-notifications.d.ts +1 -1
- package/esfaenza-signalr-notifications.metadata.json +1 -1
- package/esm2015/esfaenza-signalr-notifications.js +2 -2
- package/esm2015/lib/config/SignalrNotificationsModuleConfig.js +1 -1
- package/esm2015/lib/signalr-notifications.module.js +3 -3
- package/esm2015/lib/signalr-notifications.service.js +26 -20
- package/esm2015/lib/signalr-notifications.service.loc.js +2 -1
- package/esm2015/lib/tokens.js +2 -2
- package/fesm2015/esfaenza-signalr-notifications.js +28 -21
- package/fesm2015/esfaenza-signalr-notifications.js.map +1 -1
- package/lib/config/SignalrNotificationsModuleConfig.d.ts +1 -1
- package/lib/signalr-notifications.service.d.ts +8 -16
- package/lib/signalr-notifications.service.loc.d.ts +4 -0
- package/lib/tokens.d.ts +1 -1
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
/**
|
|
51
51
|
* Hub a cui collegarsi
|
|
52
52
|
*/
|
|
53
|
-
var
|
|
53
|
+
var ENDPOINT_URL = new core.InjectionToken('ENDPOINT_URL');
|
|
54
54
|
/**
|
|
55
55
|
* Indica se la libreria dev'essere attiva o no
|
|
56
56
|
*/
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
* Oggetto statico di localizzazione per i messaggi scritti dal servizio
|
|
77
77
|
*/
|
|
78
78
|
var Loc = {
|
|
79
|
+
"Recovering request to Endpoint": { "en-US": "Recovering request to Endpoint", "it-IT": "Recupero richiesta verso l'Endpoint" },
|
|
79
80
|
"Building SignalR Hub with Automatic Reconnection": { "en-US": "Building SignalR Hub with Automatic Reconnection", "it-IT": "Compilo l'Hub di SignalR con riconnessione automatica", },
|
|
80
81
|
"Cannot reconnect SignalR, frontend HUB offline": { "en-US": "Cannot reconnect SignalR, frontend HUB offline", "it-IT": "Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline", },
|
|
81
82
|
"Send request sent before a connection was in stable State, waiting 1 second and retrying": { "en-US": "Send request sent before a connection was in stable State, waiting 1 second and retrying", "it-IT": "Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo", },
|
|
@@ -98,34 +99,28 @@
|
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
// Angular
|
|
101
|
-
/**
|
|
102
|
-
* Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione
|
|
103
|
-
*/
|
|
102
|
+
/** Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione */
|
|
104
103
|
var NotificationsService = /** @class */ (function () {
|
|
105
|
-
/**
|
|
106
|
-
|
|
107
|
-
*
|
|
108
|
-
* @ignore
|
|
109
|
-
*/
|
|
110
|
-
function NotificationsService(MessageDef, hub_url, msgpack, enabled, debug, autoreconnect, locale) {
|
|
104
|
+
/** @ignore Costruttore */
|
|
105
|
+
function NotificationsService(MessageDef, endpoint_url, msgpack, enabled, debug, autoreconnect, locale) {
|
|
111
106
|
var _this = this;
|
|
112
107
|
this.MessageDef = MessageDef;
|
|
113
|
-
this.
|
|
108
|
+
this.endpoint_url = endpoint_url;
|
|
114
109
|
this.msgpack = msgpack;
|
|
115
110
|
this.enabled = enabled;
|
|
116
111
|
this.debug = debug;
|
|
117
112
|
this.locale = locale;
|
|
118
|
-
/**
|
|
119
|
-
* Cache degli Observable generati in base agli Endpoint disponibili
|
|
120
|
-
*/
|
|
113
|
+
/** Cache degli Observable generati in base agli Endpoint disponibili */
|
|
121
114
|
this.notifications$ = {};
|
|
115
|
+
/** Coda di chiamate da recuperare quando la connessione viene finalmente aperta */
|
|
116
|
+
this.RequestsToRecover = [];
|
|
122
117
|
if (!this.enabled) {
|
|
123
118
|
this.log(this.loc("SignalR won't be enabled as per configuration"));
|
|
124
119
|
return;
|
|
125
120
|
}
|
|
126
121
|
this.MessageDef.AllDefinitions.forEach(function (def) { _this.notifications$[def.endpoint] = new rxjs.Subject(); });
|
|
127
122
|
var pars = { skipNegotiation: true, transport: signalR__namespace.HttpTransportType.WebSockets, logger: debug ? signalR__namespace.LogLevel.Debug : signalR__namespace.LogLevel.None };
|
|
128
|
-
var builder = new signalR__namespace.HubConnectionBuilder().withUrl(this.
|
|
123
|
+
var builder = new signalR__namespace.HubConnectionBuilder().withUrl("/" + this.endpoint_url, pars);
|
|
129
124
|
if (autoreconnect) {
|
|
130
125
|
this.log(this.loc("Building SignalR Hub with Automatic Reconnection"));
|
|
131
126
|
// 100 tentativi di riconnessione, 1 ogni 5 secondi
|
|
@@ -137,14 +132,22 @@
|
|
|
137
132
|
builder = builder.withHubProtocol(new mphpModule.MessagePackHubProtocol());
|
|
138
133
|
}
|
|
139
134
|
this.connection = builder.build();
|
|
140
|
-
this.connect()
|
|
135
|
+
this.connect(function () {
|
|
136
|
+
if (_this.RequestsToRecover.length == 0)
|
|
137
|
+
return;
|
|
138
|
+
for (var i = 0; i < _this.RequestsToRecover.length; i++) {
|
|
139
|
+
_this.log(_this.loc("Recovering request to Endpoint") + " " + _this.RequestsToRecover[i].item.endpoint);
|
|
140
|
+
_this.send(_this.RequestsToRecover[i].item, _this.RequestsToRecover[i].dto);
|
|
141
|
+
}
|
|
142
|
+
_this.RequestsToRecover = [];
|
|
143
|
+
});
|
|
141
144
|
}
|
|
142
145
|
/**
|
|
143
146
|
* Effettua la connessione all'Hub Signalr e registra tutti gli Endpoint per cui il Backend comunica con il Frontend sulla **connection**
|
|
144
147
|
*/
|
|
145
|
-
NotificationsService.prototype.connect = function () {
|
|
148
|
+
NotificationsService.prototype.connect = function (onConnected) {
|
|
146
149
|
var _this = this;
|
|
147
|
-
this.connection.start().catch(function (err) { return console.log(err); });
|
|
150
|
+
this.connection.start().catch(function (err) { return console.log(err); }).then(function (_) { return onConnected === null || onConnected === void 0 ? void 0 : onConnected(); });
|
|
148
151
|
this.MessageDef.AllDefinitions.forEach(function (d) {
|
|
149
152
|
//Registro solo le cose di IN, quelle di out sono chiamate che faccio io al BE quindi non servono
|
|
150
153
|
if (d.inTypeDefault !== null && d.outTypeDefault === null)
|
|
@@ -187,6 +190,10 @@
|
|
|
187
190
|
*/
|
|
188
191
|
NotificationsService.prototype.send = function (item, dto) {
|
|
189
192
|
var _this = this;
|
|
193
|
+
if (!this.connection) {
|
|
194
|
+
this.RequestsToRecover.push({ item: item, dto: dto });
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
190
197
|
if (!this.enabled) {
|
|
191
198
|
this.log(this.loc("Send request ignored because SignalR is not active by configuration"));
|
|
192
199
|
return rxjs.EMPTY;
|
|
@@ -318,7 +325,7 @@
|
|
|
318
325
|
];
|
|
319
326
|
NotificationsService.ctorParameters = function () { return [
|
|
320
327
|
{ type: BaseMessageService },
|
|
321
|
-
{ type: String, decorators: [{ type: core.Inject, args: [
|
|
328
|
+
{ type: String, decorators: [{ type: core.Inject, args: [ENDPOINT_URL,] }] },
|
|
322
329
|
{ type: Boolean, decorators: [{ type: core.Inject, args: [MESSAGE_PACK,] }] },
|
|
323
330
|
{ type: Boolean, decorators: [{ type: core.Inject, args: [SIGNALR_ENABLED,] }] },
|
|
324
331
|
{ type: Boolean, decorators: [{ type: core.Inject, args: [DEBUG_MODE,] }] },
|
|
@@ -335,7 +342,7 @@
|
|
|
335
342
|
providers: [
|
|
336
343
|
NotificationsService,
|
|
337
344
|
{ provide: BaseMessageService, useClass: (config === null || config === void 0 ? void 0 : config.messageService) || BaseMessageService },
|
|
338
|
-
{ provide:
|
|
345
|
+
{ provide: ENDPOINT_URL, useValue: config === null || config === void 0 ? void 0 : config.endpointUrl },
|
|
339
346
|
{ provide: LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.locale) || 'it-IT' },
|
|
340
347
|
{ provide: SIGNALR_ENABLED, useValue: (config === null || config === void 0 ? void 0 : config.enabled) != null ? config === null || config === void 0 ? void 0 : config.enabled : true },
|
|
341
348
|
{ provide: DEBUG_MODE, useValue: (config === null || config === void 0 ? void 0 : config.debugMode) != null ? config === null || config === void 0 ? void 0 : config.debugMode : false },
|
|
@@ -403,7 +410,7 @@
|
|
|
403
410
|
exports.NotificationsService = NotificationsService;
|
|
404
411
|
exports.SignalrNotificationsModule = SignalrNotificationsModule;
|
|
405
412
|
exports.SignalrNotificationsModuleConfig = SignalrNotificationsModuleConfig;
|
|
406
|
-
exports["ɵa"] =
|
|
413
|
+
exports["ɵa"] = ENDPOINT_URL;
|
|
407
414
|
exports["ɵb"] = SIGNALR_ENABLED;
|
|
408
415
|
exports["ɵc"] = DEBUG_MODE;
|
|
409
416
|
exports["ɵd"] = LOCALE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esfaenza-signalr-notifications.umd.js","sources":["../../../projects/signalr-notifications/src/lib/models/BaseMessageService.ts","../../../projects/signalr-notifications/src/lib/tokens.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.loc.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.module.ts","../../../projects/signalr-notifications/src/lib/models/EndpointDef.ts","../../../projects/signalr-notifications/src/lib/config/SignalrNotificationsModuleConfig.ts","../../../projects/signalr-notifications/src/public-api.ts","../../../projects/signalr-notifications/src/esfaenza-signalr-notifications.ts"],"sourcesContent":["// Angular\r\nimport { Injectable } from '@angular/core';\r\n\r\n// Modelli\r\nimport { EndpointDef } from './EndpointDef';\r\n\r\n/**\r\n * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione\r\n */\r\n@Injectable()\r\nexport class BaseMessageService {\r\n\r\n private definitions: EndpointDef<any, any>[] = [];\r\n\r\n /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */\r\n public get AllDefinitions(): EndpointDef<any, any>[] { return this.definitions; }\r\n\r\n public add(endpoint: EndpointDef<any, any>) {\r\n this.definitions.push(endpoint);\r\n }\r\n}","import { InjectionToken } from '@angular/core';\r\n\r\n/**\r\n * Hub a cui collegarsi\r\n */\r\nexport const HUB_URL: InjectionToken<string> = new InjectionToken<string>('HUB_URL');\r\n\r\n/**\r\n * Indica se la libreria dev'essere attiva o no\r\n */\r\nexport const SIGNALR_ENABLED: InjectionToken<string> = new InjectionToken<boolean>('SIGNALR_ENABLED');\r\n\r\n/**\r\n * Indica se stampare messaggi di debug in console\r\n */\r\nexport const DEBUG_MODE: InjectionToken<string> = new InjectionToken<boolean>('DEBUG_MODE');\r\n\r\n/**\r\n * Indica il locale utilizzato dalla libreria per i messaggi. Sono supportati \"it-IT\" ed \"en-US\"\r\n */\r\nexport const LOCALE: InjectionToken<string> = new InjectionToken<string>('LOCALE');\r\n\r\n/**\r\n * Indica se utilizzare il protocollo di trasferimento \"MessagePack\"\r\n */\r\nexport const MESSAGE_PACK: InjectionToken<boolean> = new InjectionToken<boolean>('MESSAGE_PACK');\r\n\r\n/**\r\n * Indica se tentare in automatico la riconnessione\r\n */\r\nexport const AUTO_RECONNECT: InjectionToken<boolean> = new InjectionToken<boolean>('AUTO_RECONNECT');","/**\r\n * Oggetto statico di localizzazione per i messaggi scritti dal servizio\r\n */\r\nexport const Loc ={\r\n \"Building SignalR Hub with Automatic Reconnection\": { \"en-US\": \"Building SignalR Hub with Automatic Reconnection\", \"it-IT\": \"Compilo l'Hub di SignalR con riconnessione automatica\", },\r\n \"Cannot reconnect SignalR, frontend HUB offline\": { \"en-US\": \"Cannot reconnect SignalR, frontend HUB offline\", \"it-IT\": \"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline\", },\r\n \"Send request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Send request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Connection lost or missing, reconnecting...\" : { \"en-US\": \"Connection lost or missing, reconnecting...\", \"it-IT\": \"Connessione persa o mancante, mi riconnetto...\", },\r\n \"SignalR won't be enabled as per configuration\": { \"en-US\": \"SignalR won't be enabled as per configuration\", \"it-IT\": \"SignalR non verrà attivato come da configurazione\", },\r\n \"Building SignalR Hub with MessagePack protocol\": { \"en-US\": \"Building SignalR Hub with MessagePack protocol\", \"it-IT\": \"Compilo l'Hub di SignalR con protocollo MessagePack\", },\r\n \"Request received from the server for endpoint\": { \"en-US\": \"Request received from the server for endpoint\", \"it-IT\": \"Richiesta ricevuta dal server per endpoint\", },\r\n \"Refusing to register endpoint\": { \"en-US\": \"Refusing to register endpoint\", \"it-IT\": \"Rifiuto di registrare l'endpoint\", },\r\n \"because it is not declared as IN - ONLY\": { \"en-US\": \"because it is not declared as IN - ONLY\", \"it-IT\": \"in quanto non è registrato solo come IN\", },\r\n \"Send request ignored because SignalR is not active by configuration\": { \"en-US\": \"Send request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta send ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request sent to server\": { \"en-US\": \"Request sent to server\", \"it-IT\": \"Richiesta inviata al server\", },\r\n \"Invoke request ignored because SignalR is not active by configuration\": { \"en-US\": \"Invoke request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request invoked to server\": { \"en-US\": \"Request invoked to server\", \"it-IT\": \"Richiesta invoke inviata al server\", },\r\n \"Observe request ignored because SignalR is not active by configuration\": { \"en-US\": \"Observe request ignored because SignalR is not active by configuration\", \"it-IT\": \"Osservazione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Returning observable for required endpoint\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituisco l'observable per l'endpoint richiesto\", },\r\n \"Disconnection request ignored because SignalR is not active by configuration\": { \"en-US\": \"Disconnection request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Disconnection request honored\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituito observable per l'endpoint richiesto\", },\r\n \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\": { \"en-US\": \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\", \"it-IT\": \"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO\"}\r\n}","// Angular\r\nimport { Injectable, Inject } from \"@angular/core\";\r\n\r\n// Direttive, Componenti, Librerie\r\nimport * as signalR from '@microsoft/signalr';\r\nimport { HubConnectionState } from \"@microsoft/signalr\";\r\nimport { Observable, Subject, EMPTY, from, of } from \"rxjs\";\r\nimport { catchError, concatMap, delay, tap } from \"rxjs/operators\";\r\n\r\n// Modelli\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { EndpointDef } from './models/EndpointDef';\r\nimport { DEBUG_MODE, HUB_URL, LOCALE, MESSAGE_PACK, SIGNALR_ENABLED, AUTO_RECONNECT } from \"./tokens\";\r\n\r\n// Localizzazione\r\nimport { Loc } from './signalr-notifications.service.loc';\r\n\r\n/**\r\n * Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione\r\n */\r\n@Injectable()\r\nexport class NotificationsService {\r\n\r\n /**\r\n * Cache degli Observable generati in base agli Endpoint disponibili\r\n */\r\n private notifications$: { [index: string]: Subject<any> } = {};\r\n\r\n /**\r\n * Connessione Signalr\r\n */\r\n private connection: signalR.HubConnection;\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @ignore\r\n */\r\n constructor(private MessageDef: BaseMessageService, @Inject(HUB_URL) private hub_url: string, @Inject(MESSAGE_PACK) private msgpack: boolean, @Inject(SIGNALR_ENABLED) private enabled: boolean, @Inject(DEBUG_MODE) private debug: boolean, @Inject(AUTO_RECONNECT) autoreconnect: boolean, @Inject(LOCALE) private locale : string) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"SignalR won't be enabled as per configuration\"));\r\n return;\r\n }\r\n\r\n this.MessageDef.AllDefinitions.forEach(def => { this.notifications$[def.endpoint] = new Subject<typeof def.inTypeDefault>(); });\r\n\r\n let pars: signalR.IHttpConnectionOptions = { skipNegotiation: true, transport: signalR.HttpTransportType.WebSockets, logger: debug ? signalR.LogLevel.Debug : signalR.LogLevel.None };\r\n var builder = new signalR.HubConnectionBuilder().withUrl(this.hub_url, pars);\r\n\r\n if (autoreconnect) {\r\n this.log(this.loc(\"Building SignalR Hub with Automatic Reconnection\"));\r\n // 100 tentativi di riconnessione, 1 ogni 5 secondi\r\n builder = builder.withAutomaticReconnect(new Array(100).fill(5 * 1000));\r\n }\r\n\r\n if (this.msgpack) {\r\n this.log(this.loc(\"Building SignalR Hub with MessagePack protocol\"));\r\n var mphpModule = require(\"@microsoft/signalr-protocol-msgpack\");\r\n builder = builder.withHubProtocol(new mphpModule.MessagePackHubProtocol())\r\n }\r\n\r\n this.connection = builder.build();\r\n this.connect();\r\n }\r\n\r\n /**\r\n * Effettua la connessione all'Hub Signalr e registra tutti gli Endpoint per cui il Backend comunica con il Frontend sulla **connection**\r\n */\r\n private connect() {\r\n this.connection.start().catch(err => console.log(err));\r\n this.MessageDef.AllDefinitions.forEach(d => {\r\n //Registro solo le cose di IN, quelle di out sono chiamate che faccio io al BE quindi non servono\r\n if (d.inTypeDefault !== null && d.outTypeDefault === null)\r\n this.connection.on(d.endpoint, (message) => {\r\n this.log(this.loc(\"Request received from the server for endpoint\") + \" '\" + d.endpoint + \"': \" + this.substringLog(JSON.stringify(message)));\r\n this.notifications$[d.endpoint].next(message);\r\n });\r\n else\r\n this.log(this.loc(\"Refusing to register endpoint\") + \" \" + d.endpoint + \" \" + this.loc(\"because it is not declared as IN - ONLY\"));\r\n });\r\n }\r\n\r\n /**\r\n * Effettua verifiche sulla connessione e, in caso non fosse collegata, tenta di riconnetterla\r\n * \r\n * @returns {Promise<'OK' | 'KO' | 'NO-OP'>} 'OK' Se la connessione è già connessa o è stata riconnessa con successo, 'KO' Se non è stato possibile riconnettere \r\n * una connessione disconnessa, 'NO-OP' se la connesisone è in uno stato intermedio che non può essere modificato\r\n */\r\n public ensureConnected(): Promise<'OK' | 'KO' | 'NO-OP'> {\r\n if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.log(this.loc(\"Connection lost or missing, reconnecting...\"));\r\n\r\n return this.connection.start()\r\n .then(_ => {\r\n return Promise.resolve(\"OK\");\r\n }, _ => {\r\n this.log(this.loc(\"Cannot reconnect SignalR, frontend HUB offline\"));\r\n return Promise.resolve(\"KO\");\r\n });\r\n }\r\n else if (this.connection.state == HubConnectionState.Connected)\r\n return Promise.resolve(\"OK\");\r\n else\r\n return Promise.resolve(\"NO-OP\");\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend\r\n * \r\n * @param {EndpointDef<TOut, any>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n */\r\n public send<TOut>(item: EndpointDef<TOut, any>, dto: TOut) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Send request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Send request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n setTimeout(() => { this.send(item, dto); }, 1000);\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.ensureConnected().then(t => {\r\n if (t == \"KO\") this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n else this.send(item, dto);\r\n })\r\n }\r\n else {\r\n this.connection.send(item.endpoint, dto).then(_ => {\r\n if (this.debug)\r\n console.info(this.loc(\"Request sent to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend, aspettandosi una risposta\r\n * \r\n * @param {EndpointDef<TOut, TIn>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere il risultato della chiamata\r\n */\r\n public invoke<TOut, TIn>(item: EndpointDef<TOut, TIn>, dto: TOut): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Invoke request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n return of().pipe(delay(1000), concatMap(() => this.invoke(item, dto)));\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n return from(this.ensureConnected()).pipe(concatMap((res) => {\r\n if (res == \"KO\") {\r\n this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n return EMPTY;\r\n }\r\n else return this.invoke(item, dto);\r\n }))\r\n }\r\n else {\r\n return from(this.connection.invoke<TIn>(item.endpoint, dto)).pipe(\r\n tap(() => {\r\n if (this.debug) console.log(this.loc(\"Request invoked to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n })\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Hook per osservare i dati spediti ad un Endpoint dal Backend\r\n * \r\n * @param {EndpointDef<TIn, any>} item Endpoint su cui ascoltare\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere l'oggetto generato ad ogni chiamata dal Backend al Frontend\r\n */\r\n public observe<TIn>(item: EndpointDef<TIn, any>): Observable<TIn> {\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Observe request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n this.log(this.loc(\"Returning observable for required endpoint\") + \": \" + item.endpoint);\r\n return <Observable<TIn>>this.notifications$[item.endpoint];\r\n }\r\n\r\n /**\r\n * Disconnessione del sistema di SignalR\r\n * \r\n * @returns {Observable<void>} Observable a cui registrarsi che viene chiamato quando la disconnessione è terminata\r\n */\r\n public disconnect(): Observable<void> {\r\n //NO-OP se non attivo\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Disconnection request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n return from(this.connection.stop()).pipe(\r\n catchError((err, caught) => { console.log(err); return of(null); }),\r\n tap(() => {\r\n this.log(this.loc(\"Disconnection request honored\"));\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Taglia un log troppo lungo\r\n * \r\n * @param {string} text Log da tagliare\r\n * @param {number} maxchars Numero massimo di caratteri da tenere\r\n * \r\n * @returns {string} Log tagliato\r\n */\r\n private substringLog(text: string, maxchars: number = 120) : string {\r\n return text.length > maxchars ? text.substr(0, maxchars) + \"[...]\" : text;\r\n }\r\n\r\n /**\r\n * Stampa un log a console\r\n * \r\n * @param {string} message Messaggio da stampare\r\n */\r\n private log(message: string) {\r\n if (this.debug)\r\n console.log(\"@signalr-notifications: \" + message)\r\n }\r\n\r\n /**\r\n * Helper di localizzazione\r\n * \r\n * @param {string} message Messaggio da tradurre\r\n * \r\n * @returns {string} Messaggio tradotto\r\n */\r\n private loc(message: string) : string{\r\n if(!Loc[message])\r\n {\r\n console.warn(\"Untranslated message: \" + message)\r\n return \"\";\r\n }\r\n return Loc[message][this.locale];\r\n }\r\n}","\r\nimport { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { SignalrNotificationsModuleConfig } from './config/SignalrNotificationsModuleConfig';\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { NotificationsService } from './signalr-notifications.service';\r\nimport { HUB_URL, SIGNALR_ENABLED, DEBUG_MODE, LOCALE, MESSAGE_PACK, AUTO_RECONNECT } from './tokens';\r\n\r\n@NgModule()\r\nexport class SignalrNotificationsModule {\r\n static forRoot(config?: SignalrNotificationsModuleConfig): ModuleWithProviders<SignalrNotificationsModule> {\r\n return {\r\n ngModule: SignalrNotificationsModule,\r\n providers: [\r\n NotificationsService,\r\n { provide: BaseMessageService, useClass: config?.messageService || BaseMessageService },\r\n { provide: HUB_URL, useValue: config?.hubUrl },\r\n { provide: LOCALE, useValue: config?.locale || 'it-IT' },\r\n { provide: SIGNALR_ENABLED, useValue: config?.enabled != null ? config?.enabled : true },\r\n { provide: DEBUG_MODE, useValue: config?.debugMode != null ? config?.debugMode : false },\r\n { provide: MESSAGE_PACK, useValue: config?.autoReconnect != null ? config?.autoReconnect : false },\r\n { provide: AUTO_RECONNECT, useValue: config?.useMessagePack != null ? config?.useMessagePack : false },\r\n ]\r\n };\r\n }\r\n}","/**\r\n * Definisce un Endpoint che spedisce un'informazione di tipo TIn e restituisce un'informazione di tipo TOut\r\n */\r\nexport class EndpointDef<TIn, TOut> {\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @param {string} endpoint Nome del metodo da chiamare nell'Hub del Backend contattato\r\n * @param {TIn} inTypeDefault Default per il tipo TIn. Utilizzato per fare Typecheck sulle chiamate da Backend a Frontend\r\n * @param {TOut} outTypeDefault Default per il tipo TOut. Utilizzato per fare Typecheck sulle chiamate da Frontend a Backend\r\n */\r\n constructor(public endpoint: string, public inTypeDefault: TIn, public outTypeDefault: TOut) { }\r\n\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo INPUT */\r\n public static In<TIn>(name: string, inTypeDefault: TIn): EndpointDef<TIn, void> {\r\n return new EndpointDef<TIn, void>(name, inTypeDefault, undefined);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */\r\n public static Out<TOut>(name: string, outTypeDefault: TOut): EndpointDef<void, TOut> {\r\n return new EndpointDef<void, TOut>(name, undefined, outTypeDefault);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */\r\n public static Bi<TIn, TOut>(name: string, inTypeDefault: TIn, outTypeDefault: TOut): EndpointDef<TIn, TOut> {\r\n return new EndpointDef<TIn, TOut>(name, inTypeDefault, outTypeDefault);\r\n }\r\n}","// Angular\r\nimport { Type } from '@angular/core';\r\n\r\n// Modelli\r\nimport { BaseMessageService } from '../models/BaseMessageService';\r\n\r\n/**\r\n * Classe di configurazione per la libreria\r\n */\r\nexport class SignalrNotificationsModuleConfig {\r\n\r\n /**\r\n * Url nei confronti del quale aprire la connessione SignalR\r\n */\r\n hubUrl : string;\r\n\r\n /**\r\n * Servizio che definisce i messaggi di IN e OUT coi loro default\r\n */\r\n messageService? : Type<BaseMessageService>;\r\n\r\n /**\r\n * Indica se abilitare o meno la connessione SignalR nei confronti dell'URL **hubUrl**\r\n */\r\n enabled? : boolean;\r\n\r\n /**\r\n * Indica se utilizzare message pack come protocollo di trasmissione\r\n */\r\n useMessagePack? : boolean;\r\n\r\n /**\r\n * Indica se tentare di riconnettersi automaticamente quando la connessione cade\r\n */\r\n autoReconnect? : boolean;\r\n\r\n /**\r\n * Indica se scrivere o meno i messaggi di debug\r\n */\r\n debugMode? : boolean;\r\n\r\n /**\r\n * Lingua dei feedback a console, sono supportati 'it-IT' ed 'en-US'\r\n */\r\n locale? : string\r\n}","/*\n * Public API Surface of signalr-notifications\n */\n\nexport * from './lib/signalr-notifications.service';\nexport * from './lib/signalr-notifications.module';\nexport * from './lib/models/BaseMessageService';\nexport * from './lib/models/EndpointDef';\nexport * from './lib/config/SignalrNotificationsModuleConfig';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n\nexport {AUTO_RECONNECT as ɵf,DEBUG_MODE as ɵc,HUB_URL as ɵa,LOCALE as ɵd,MESSAGE_PACK as ɵe,SIGNALR_ENABLED as ɵb} from './lib/tokens';"],"names":["Injectable","InjectionToken","Subject","signalR","HubConnectionState","EMPTY","of","delay","concatMap","from","tap","catchError","Inject","NgModule"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;IAMA;;;;QAGA;YAGY,gBAAW,GAA4B,EAAE,CAAC;SAQrD;QALG,sBAAW,8CAAc;;iBAAzB,cAAuD,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE;;;WAAA;QAE1E,gCAAG,GAAH,UAAI,QAA+B;YACtC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACnC;;;;gBAVJA,eAAU;;;ICPX;;;QAGa,OAAO,GAA2B,IAAIC,mBAAc,CAAS,SAAS,EAAE;IAErF;;;QAGa,eAAe,GAA2B,IAAIA,mBAAc,CAAU,iBAAiB,EAAE;IAEtG;;;QAGa,UAAU,GAA2B,IAAIA,mBAAc,CAAU,YAAY,EAAE;IAE5F;;;QAGa,MAAM,GAA2B,IAAIA,mBAAc,CAAS,QAAQ,EAAE;IAEnF;;;QAGa,YAAY,GAA4B,IAAIA,mBAAc,CAAU,cAAc,EAAE;IAEjG;;;QAGa,cAAc,GAA4B,IAAIA,mBAAc,CAAU,gBAAgB;;IC9BnG;;;IAGO,IAAM,GAAG,GAAE;QACd,kDAAkD,EAAE,EAAE,OAAO,EAAE,kDAAkD,EAAE,OAAO,EAAE,uDAAuD,GAAG;QACtL,gDAAgD,EAAE,EAAE,OAAO,EAAE,gDAAgD,EAAE,OAAO,EAAE,iEAAiE,GAAG;QAC5L,0FAA0F,EAAE,EAAE,OAAO,EAAE,0FAA0F,EAAE,OAAO,EAAE,4GAA4G,GAAG;QAC3T,4FAA4F,EAAE,EAAE,OAAO,EAAE,4FAA4F,EA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lib/models/BaseMessageService.ts","../../../projects/signalr-notifications/src/lib/tokens.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.loc.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.module.ts","../../../projects/signalr-notifications/src/lib/models/EndpointDef.ts","../../../projects/signalr-notifications/src/lib/config/SignalrNotificationsModuleConfig.ts","../../../projects/signalr-notifications/src/public-api.ts","../../../projects/signalr-notifications/src/esfaenza-signalr-notifications.ts"],"sourcesContent":["// Angular\r\nimport { Injectable } from '@angular/core';\r\n\r\n// Modelli\r\nimport { EndpointDef } from './EndpointDef';\r\n\r\n/**\r\n * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione\r\n */\r\n@Injectable()\r\nexport class BaseMessageService {\r\n\r\n private definitions: EndpointDef<any, any>[] = [];\r\n\r\n /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */\r\n public get AllDefinitions(): EndpointDef<any, any>[] { return this.definitions; }\r\n\r\n public add(endpoint: EndpointDef<any, any>) {\r\n this.definitions.push(endpoint);\r\n }\r\n}","import { InjectionToken } from '@angular/core';\r\n\r\n/**\r\n * Hub a cui collegarsi\r\n */\r\nexport const ENDPOINT_URL: InjectionToken<string> = new InjectionToken<string>('ENDPOINT_URL');\r\n\r\n/**\r\n * Indica se la libreria dev'essere attiva o no\r\n */\r\nexport const SIGNALR_ENABLED: InjectionToken<string> = new InjectionToken<boolean>('SIGNALR_ENABLED');\r\n\r\n/**\r\n * Indica se stampare messaggi di debug in console\r\n */\r\nexport const DEBUG_MODE: InjectionToken<string> = new InjectionToken<boolean>('DEBUG_MODE');\r\n\r\n/**\r\n * Indica il locale utilizzato dalla libreria per i messaggi. Sono supportati \"it-IT\" ed \"en-US\"\r\n */\r\nexport const LOCALE: InjectionToken<string> = new InjectionToken<string>('LOCALE');\r\n\r\n/**\r\n * Indica se utilizzare il protocollo di trasferimento \"MessagePack\"\r\n */\r\nexport const MESSAGE_PACK: InjectionToken<boolean> = new InjectionToken<boolean>('MESSAGE_PACK');\r\n\r\n/**\r\n * Indica se tentare in automatico la riconnessione\r\n */\r\nexport const AUTO_RECONNECT: InjectionToken<boolean> = new InjectionToken<boolean>('AUTO_RECONNECT');","/**\r\n * Oggetto statico di localizzazione per i messaggi scritti dal servizio\r\n */\r\nexport const Loc ={\r\n \"Recovering request to Endpoint\": {\"en-US\": \"Recovering request to Endpoint\", \"it-IT\": \"Recupero richiesta verso l'Endpoint\"},\r\n \"Building SignalR Hub with Automatic Reconnection\": { \"en-US\": \"Building SignalR Hub with Automatic Reconnection\", \"it-IT\": \"Compilo l'Hub di SignalR con riconnessione automatica\", },\r\n \"Cannot reconnect SignalR, frontend HUB offline\": { \"en-US\": \"Cannot reconnect SignalR, frontend HUB offline\", \"it-IT\": \"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline\", },\r\n \"Send request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Send request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Connection lost or missing, reconnecting...\" : { \"en-US\": \"Connection lost or missing, reconnecting...\", \"it-IT\": \"Connessione persa o mancante, mi riconnetto...\", },\r\n \"SignalR won't be enabled as per configuration\": { \"en-US\": \"SignalR won't be enabled as per configuration\", \"it-IT\": \"SignalR non verrà attivato come da configurazione\", },\r\n \"Building SignalR Hub with MessagePack protocol\": { \"en-US\": \"Building SignalR Hub with MessagePack protocol\", \"it-IT\": \"Compilo l'Hub di SignalR con protocollo MessagePack\", },\r\n \"Request received from the server for endpoint\": { \"en-US\": \"Request received from the server for endpoint\", \"it-IT\": \"Richiesta ricevuta dal server per endpoint\", },\r\n \"Refusing to register endpoint\": { \"en-US\": \"Refusing to register endpoint\", \"it-IT\": \"Rifiuto di registrare l'endpoint\", },\r\n \"because it is not declared as IN - ONLY\": { \"en-US\": \"because it is not declared as IN - ONLY\", \"it-IT\": \"in quanto non è registrato solo come IN\", },\r\n \"Send request ignored because SignalR is not active by configuration\": { \"en-US\": \"Send request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta send ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request sent to server\": { \"en-US\": \"Request sent to server\", \"it-IT\": \"Richiesta inviata al server\", },\r\n \"Invoke request ignored because SignalR is not active by configuration\": { \"en-US\": \"Invoke request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request invoked to server\": { \"en-US\": \"Request invoked to server\", \"it-IT\": \"Richiesta invoke inviata al server\", },\r\n \"Observe request ignored because SignalR is not active by configuration\": { \"en-US\": \"Observe request ignored because SignalR is not active by configuration\", \"it-IT\": \"Osservazione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Returning observable for required endpoint\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituisco l'observable per l'endpoint richiesto\", },\r\n \"Disconnection request ignored because SignalR is not active by configuration\": { \"en-US\": \"Disconnection request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Disconnection request honored\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituito observable per l'endpoint richiesto\", },\r\n \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\": { \"en-US\": \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\", \"it-IT\": \"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO\"}\r\n}","// Angular\r\nimport { Injectable, Inject } from \"@angular/core\";\r\n\r\n// Direttive, Componenti, Librerie\r\nimport * as signalR from '@microsoft/signalr';\r\nimport { HubConnectionState } from \"@microsoft/signalr\";\r\nimport { Observable, Subject, EMPTY, from, of } from \"rxjs\";\r\nimport { catchError, concatMap, delay, tap } from \"rxjs/operators\";\r\n\r\n// Modelli\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { EndpointDef } from './models/EndpointDef';\r\nimport { DEBUG_MODE, ENDPOINT_URL, LOCALE, MESSAGE_PACK, SIGNALR_ENABLED, AUTO_RECONNECT } from \"./tokens\";\r\n\r\n// Localizzazione\r\nimport { Loc } from './signalr-notifications.service.loc';\r\n\r\n/** Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione */\r\n@Injectable()\r\nexport class NotificationsService {\r\n\r\n /** Cache degli Observable generati in base agli Endpoint disponibili */\r\n private notifications$: { [index: string]: Subject<any> } = {};\r\n\r\n /** Connessione Signalr */\r\n private connection: signalR.HubConnection;\r\n\r\n /** Coda di chiamate da recuperare quando la connessione viene finalmente aperta */\r\n private RequestsToRecover: { item: EndpointDef<any, any>, dto: any }[] = [];\r\n\r\n /** @ignore Costruttore */\r\n constructor(private MessageDef: BaseMessageService, @Inject(ENDPOINT_URL) private endpoint_url: string, @Inject(MESSAGE_PACK) private msgpack: boolean, @Inject(SIGNALR_ENABLED) private enabled: boolean, @Inject(DEBUG_MODE) private debug: boolean, @Inject(AUTO_RECONNECT) autoreconnect: boolean, @Inject(LOCALE) private locale: string) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"SignalR won't be enabled as per configuration\"));\r\n return;\r\n }\r\n\r\n this.MessageDef.AllDefinitions.forEach(def => { this.notifications$[def.endpoint] = new Subject<typeof def.inTypeDefault>(); });\r\n\r\n let pars: signalR.IHttpConnectionOptions = { skipNegotiation: true, transport: signalR.HttpTransportType.WebSockets, logger: debug ? signalR.LogLevel.Debug : signalR.LogLevel.None };\r\n var builder = new signalR.HubConnectionBuilder().withUrl(\"/\" + this.endpoint_url, pars);\r\n\r\n if (autoreconnect) {\r\n this.log(this.loc(\"Building SignalR Hub with Automatic Reconnection\"));\r\n // 100 tentativi di riconnessione, 1 ogni 5 secondi\r\n builder = builder.withAutomaticReconnect(new Array(100).fill(5 * 1000));\r\n }\r\n\r\n if (this.msgpack) {\r\n this.log(this.loc(\"Building SignalR Hub with MessagePack protocol\"));\r\n var mphpModule = require(\"@microsoft/signalr-protocol-msgpack\");\r\n builder = builder.withHubProtocol(new mphpModule.MessagePackHubProtocol())\r\n }\r\n\r\n this.connection = builder.build();\r\n this.connect(() => {\r\n if (this.RequestsToRecover.length == 0)\r\n return;\r\n\r\n for (let i = 0; i < this.RequestsToRecover.length; i++) {\r\n this.log(this.loc(\"Recovering request to Endpoint\") + \" \" + this.RequestsToRecover[i].item.endpoint)\r\n this.send(this.RequestsToRecover[i].item, this.RequestsToRecover[i].dto);\r\n }\r\n\r\n this.RequestsToRecover = [];\r\n });\r\n }\r\n\r\n /**\r\n * Effettua la connessione all'Hub Signalr e registra tutti gli Endpoint per cui il Backend comunica con il Frontend sulla **connection**\r\n */\r\n private connect(onConnected?: () => void) {\r\n this.connection.start().catch(err => console.log(err)).then(_ => onConnected?.());\r\n this.MessageDef.AllDefinitions.forEach(d => {\r\n //Registro solo le cose di IN, quelle di out sono chiamate che faccio io al BE quindi non servono\r\n if (d.inTypeDefault !== null && d.outTypeDefault === null)\r\n this.connection.on(d.endpoint, (message) => {\r\n this.log(this.loc(\"Request received from the server for endpoint\") + \" '\" + d.endpoint + \"': \" + this.substringLog(JSON.stringify(message)));\r\n this.notifications$[d.endpoint].next(message);\r\n });\r\n else\r\n this.log(this.loc(\"Refusing to register endpoint\") + \" \" + d.endpoint + \" \" + this.loc(\"because it is not declared as IN - ONLY\"));\r\n });\r\n }\r\n\r\n /**\r\n * Effettua verifiche sulla connessione e, in caso non fosse collegata, tenta di riconnetterla\r\n * \r\n * @returns {Promise<'OK' | 'KO' | 'NO-OP'>} 'OK' Se la connessione è già connessa o è stata riconnessa con successo, 'KO' Se non è stato possibile riconnettere \r\n * una connessione disconnessa, 'NO-OP' se la connesisone è in uno stato intermedio che non può essere modificato\r\n */\r\n public ensureConnected(): Promise<'OK' | 'KO' | 'NO-OP'> {\r\n if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.log(this.loc(\"Connection lost or missing, reconnecting...\"));\r\n\r\n return this.connection.start()\r\n .then(_ => {\r\n return Promise.resolve(\"OK\");\r\n }, _ => {\r\n this.log(this.loc(\"Cannot reconnect SignalR, frontend HUB offline\"));\r\n return Promise.resolve(\"KO\");\r\n });\r\n }\r\n else if (this.connection.state == HubConnectionState.Connected)\r\n return Promise.resolve(\"OK\");\r\n else\r\n return Promise.resolve(\"NO-OP\");\r\n }\r\n\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend\r\n * \r\n * @param {EndpointDef<TOut, any>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n */\r\n public send<TOut>(item: EndpointDef<TOut, any>, dto: TOut) {\r\n if (!this.connection) {\r\n this.RequestsToRecover.push({ item, dto });\r\n return;\r\n }\r\n\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Send request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Send request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n setTimeout(() => { this.send(item, dto); }, 1000);\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.ensureConnected().then(t => {\r\n if (t == \"KO\") this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n else this.send(item, dto);\r\n })\r\n }\r\n else {\r\n this.connection.send(item.endpoint, dto).then(_ => {\r\n if (this.debug)\r\n console.info(this.loc(\"Request sent to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend, aspettandosi una risposta\r\n * \r\n * @param {EndpointDef<TOut, TIn>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere il risultato della chiamata\r\n */\r\n public invoke<TOut, TIn>(item: EndpointDef<TOut, TIn>, dto: TOut): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Invoke request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n return of().pipe(delay(1000), concatMap(() => this.invoke(item, dto)));\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n return from(this.ensureConnected()).pipe(concatMap((res) => {\r\n if (res == \"KO\") {\r\n this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n return EMPTY;\r\n }\r\n else return this.invoke(item, dto);\r\n }))\r\n }\r\n else {\r\n return from(this.connection.invoke<TIn>(item.endpoint, dto)).pipe(\r\n tap(() => {\r\n if (this.debug) console.log(this.loc(\"Request invoked to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n })\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Hook per osservare i dati spediti ad un Endpoint dal Backend\r\n * \r\n * @param {EndpointDef<TIn, any>} item Endpoint su cui ascoltare\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere l'oggetto generato ad ogni chiamata dal Backend al Frontend\r\n */\r\n public observe<TIn>(item: EndpointDef<TIn, any>): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Observe request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n this.log(this.loc(\"Returning observable for required endpoint\") + \": \" + item.endpoint);\r\n return <Observable<TIn>>this.notifications$[item.endpoint];\r\n }\r\n\r\n /**\r\n * Disconnessione del sistema di SignalR\r\n * \r\n * @returns {Observable<void>} Observable a cui registrarsi che viene chiamato quando la disconnessione è terminata\r\n */\r\n public disconnect(): Observable<void> {\r\n //NO-OP se non attivo\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Disconnection request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n return from(this.connection.stop()).pipe(\r\n catchError((err, caught) => { console.log(err); return of(null); }),\r\n tap(() => {\r\n this.log(this.loc(\"Disconnection request honored\"));\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Taglia un log troppo lungo\r\n * \r\n * @param {string} text Log da tagliare\r\n * @param {number} maxchars Numero massimo di caratteri da tenere\r\n * \r\n * @returns {string} Log tagliato\r\n */\r\n private substringLog(text: string, maxchars: number = 120): string {\r\n return text.length > maxchars ? text.substr(0, maxchars) + \"[...]\" : text;\r\n }\r\n\r\n /**\r\n * Stampa un log a console\r\n * \r\n * @param {string} message Messaggio da stampare\r\n */\r\n private log(message: string) {\r\n if (this.debug)\r\n console.log(\"@signalr-notifications: \" + message)\r\n }\r\n\r\n /**\r\n * Helper di localizzazione\r\n * \r\n * @param {string} message Messaggio da tradurre\r\n * \r\n * @returns {string} Messaggio tradotto\r\n */\r\n private loc(message: string): string {\r\n if (!Loc[message]) {\r\n console.warn(\"Untranslated message: \" + message)\r\n return \"\";\r\n }\r\n return Loc[message][this.locale];\r\n }\r\n}","\r\nimport { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { SignalrNotificationsModuleConfig } from './config/SignalrNotificationsModuleConfig';\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { NotificationsService } from './signalr-notifications.service';\r\nimport { ENDPOINT_URL, SIGNALR_ENABLED, DEBUG_MODE, LOCALE, MESSAGE_PACK, AUTO_RECONNECT } from './tokens';\r\n\r\n@NgModule()\r\nexport class SignalrNotificationsModule {\r\n static forRoot(config?: SignalrNotificationsModuleConfig): ModuleWithProviders<SignalrNotificationsModule> {\r\n return {\r\n ngModule: SignalrNotificationsModule,\r\n providers: [\r\n NotificationsService,\r\n { provide: BaseMessageService, useClass: config?.messageService || BaseMessageService },\r\n { provide: ENDPOINT_URL, useValue: config?.endpointUrl },\r\n { provide: LOCALE, useValue: config?.locale || 'it-IT' },\r\n { provide: SIGNALR_ENABLED, useValue: config?.enabled != null ? config?.enabled : true },\r\n { provide: DEBUG_MODE, useValue: config?.debugMode != null ? config?.debugMode : false },\r\n { provide: MESSAGE_PACK, useValue: config?.autoReconnect != null ? config?.autoReconnect : false },\r\n { provide: AUTO_RECONNECT, useValue: config?.useMessagePack != null ? config?.useMessagePack : false },\r\n ]\r\n };\r\n }\r\n}","/**\r\n * Definisce un Endpoint che spedisce un'informazione di tipo TIn e restituisce un'informazione di tipo TOut\r\n */\r\nexport class EndpointDef<TIn, TOut> {\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @param {string} endpoint Nome del metodo da chiamare nell'Hub del Backend contattato\r\n * @param {TIn} inTypeDefault Default per il tipo TIn. Utilizzato per fare Typecheck sulle chiamate da Backend a Frontend\r\n * @param {TOut} outTypeDefault Default per il tipo TOut. Utilizzato per fare Typecheck sulle chiamate da Frontend a Backend\r\n */\r\n constructor(public endpoint: string, public inTypeDefault: TIn, public outTypeDefault: TOut) { }\r\n\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo INPUT */\r\n public static In<TIn>(name: string, inTypeDefault: TIn): EndpointDef<TIn, void> {\r\n return new EndpointDef<TIn, void>(name, inTypeDefault, undefined);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */\r\n public static Out<TOut>(name: string, outTypeDefault: TOut): EndpointDef<void, TOut> {\r\n return new EndpointDef<void, TOut>(name, undefined, outTypeDefault);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */\r\n public static Bi<TIn, TOut>(name: string, inTypeDefault: TIn, outTypeDefault: TOut): EndpointDef<TIn, TOut> {\r\n return new EndpointDef<TIn, TOut>(name, inTypeDefault, outTypeDefault);\r\n }\r\n}","// Angular\r\nimport { Type } from '@angular/core';\r\n\r\n// Modelli\r\nimport { BaseMessageService } from '../models/BaseMessageService';\r\n\r\n/**\r\n * Classe di configurazione per la libreria\r\n */\r\nexport class SignalrNotificationsModuleConfig {\r\n\r\n /**\r\n * Url nei confronti del quale aprire la connessione SignalR\r\n */\r\n endpointUrl : string;\r\n\r\n /**\r\n * Servizio che definisce i messaggi di IN e OUT coi loro default\r\n */\r\n messageService? : Type<BaseMessageService>;\r\n\r\n /**\r\n * Indica se abilitare o meno la connessione SignalR nei confronti dell'URL **hubUrl**\r\n */\r\n enabled? : boolean;\r\n\r\n /**\r\n * Indica se utilizzare message pack come protocollo di trasmissione\r\n */\r\n useMessagePack? : boolean;\r\n\r\n /**\r\n * Indica se tentare di riconnettersi automaticamente quando la connessione cade\r\n */\r\n autoReconnect? : boolean;\r\n\r\n /**\r\n * Indica se scrivere o meno i messaggi di debug\r\n */\r\n debugMode? : boolean;\r\n\r\n /**\r\n * Lingua dei feedback a console, sono supportati 'it-IT' ed 'en-US'\r\n */\r\n locale? : string\r\n}","/*\n * Public API Surface of signalr-notifications\n */\n\nexport * from './lib/signalr-notifications.service';\nexport * from './lib/signalr-notifications.module';\nexport * from './lib/models/BaseMessageService';\nexport * from './lib/models/EndpointDef';\nexport * from './lib/config/SignalrNotificationsModuleConfig';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n\nexport {AUTO_RECONNECT as ɵf,DEBUG_MODE as ɵc,ENDPOINT_URL as ɵa,LOCALE as ɵd,MESSAGE_PACK as ɵe,SIGNALR_ENABLED as ɵb} from './lib/tokens';"],"names":["Injectable","InjectionToken","Subject","signal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CAAC;SACH;;;;gBAhBFC,aAAQ;;;ICPT;;;;;;;;;;;QAYI,qBAAmB,QAAgB,EAAS,aAAkB,EAAS,cAAoB;YAAxE,aAAQ,GAAR,QAAQ,CAAQ;YAAS,kBAAa,GAAb,aAAa,CAAK;YAAS,mBAAc,GAAd,cAAc,CAAM;SAAK;;QAIlF,cAAE,GAAT,UAAe,IAAY,EAAE,aAAkB;YAClD,OAAO,IAAI,WAAW,CAAY,IAAI,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;SACrE;;QAGa,eAAG,GAAV,UAAiB,IAAY,EAAE,cAAoB;YACtD,OAAO,IAAI,WAAW,CAAa,IAAI,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;SACvE;;QAGa,cAAE,GAAT,UAAqB,IAAY,EAAE,aAAkB,EAAE,cAAoB;YAC9E,OAAO,IAAI,WAAW,CAAY,IAAI,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;SAC1E;0BACJ;KAAA;;ICvBD;;;;QAGA;SAoCC;+CAAA;KAAA;;IC7CD;;;;ICAA;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/core"),require("@microsoft/signalr"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@esfaenza/signalr-notifications",["exports","@angular/core","@microsoft/signalr","rxjs","rxjs/operators"],n):n(((e="undefined"!=typeof globalThis?globalThis:e||self).esfaenza=e.esfaenza||{},e.esfaenza["signalr-notifications"]={}),e.ng.core,e.signalR,e.rxjs,e.rxjs.operators)}(this,(function(e,n,t,o,i){"use strict";function s(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var r=s(t),a=function(){function e(){this.definitions=[]}return Object.defineProperty(e.prototype,"AllDefinitions",{get:function(){return this.definitions},enumerable:!1,configurable:!0}),e.prototype.add=function(e){this.definitions.push(e)},e}();a.decorators=[{type:n.Injectable}];var c=new n.InjectionToken("HUB_URL"),u=new n.InjectionToken("SIGNALR_ENABLED"),l=new n.InjectionToken("DEBUG_MODE"),g=new n.InjectionToken("LOCALE"),d=new n.InjectionToken("MESSAGE_PACK"),f=new n.InjectionToken("AUTO_RECONNECT"),p={"Building SignalR Hub with Automatic Reconnection":{"en-US":"Building SignalR Hub with Automatic Reconnection","it-IT":"Compilo l'Hub di SignalR con riconnessione automatica"},"Cannot reconnect SignalR, frontend HUB offline":{"en-US":"Cannot reconnect SignalR, frontend HUB offline","it-IT":"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline"},"Send request sent before a connection was in stable State, waiting 1 second and retrying":{"en-US":"Send request sent before a connection was in stable State, waiting 1 second and retrying","it-IT":"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo"},"Invoke request sent before a connection was in stable State, waiting 1 second and retrying":{"en-US":"Invoke request sent before a connection was in stable State, waiting 1 second and retrying","it-IT":"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo"},"Connection lost or missing, reconnecting...":{"en-US":"Connection lost or missing, reconnecting...","it-IT":"Connessione persa o mancante, mi riconnetto..."},"SignalR won't be enabled as per configuration":{"en-US":"SignalR won't be enabled as per configuration","it-IT":"SignalR non verrà attivato come da configurazione"},"Building SignalR Hub with MessagePack protocol":{"en-US":"Building SignalR Hub with MessagePack protocol","it-IT":"Compilo l'Hub di SignalR con protocollo MessagePack"},"Request received from the server for endpoint":{"en-US":"Request received from the server for endpoint","it-IT":"Richiesta ricevuta dal server per endpoint"},"Refusing to register endpoint":{"en-US":"Refusing to register endpoint","it-IT":"Rifiuto di registrare l'endpoint"},"because it is not declared as IN - ONLY":{"en-US":"because it is not declared as IN - ONLY","it-IT":"in quanto non è registrato solo come IN"},"Send request ignored because SignalR is not active by configuration":{"en-US":"Send request ignored because SignalR is not active by configuration","it-IT":"Richiesta send ignorata in quanto SignalR non è attivo da configurazione"},"Request sent to server":{"en-US":"Request sent to server","it-IT":"Richiesta inviata al server"},"Invoke request ignored because SignalR is not active by configuration":{"en-US":"Invoke request ignored because SignalR is not active by configuration","it-IT":"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione"},"Request invoked to server":{"en-US":"Request invoked to server","it-IT":"Richiesta invoke inviata al server"},"Observe request ignored because SignalR is not active by configuration":{"en-US":"Observe request ignored because SignalR is not active by configuration","it-IT":"Osservazione ignorata in quanto SignalR non è attivo da configurazione"},"Returning observable for required endpoint":{"en-US":"Returning observable for required endpoint","it-IT":"Restituisco l'observable per l'endpoint richiesto"},"Disconnection request ignored because SignalR is not active by configuration":{"en-US":"Disconnection request ignored because SignalR is not active by configuration","it-IT":"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione"},"Disconnection request honored":{"en-US":"Returning observable for required endpoint","it-IT":"Restituito observable per l'endpoint richiesto"},"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST":{"en-US":"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST","it-IT":"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO"}},b=function(){function e(e,n,t,i,s,a,c){var u=this;if(this.MessageDef=e,this.hub_url=n,this.msgpack=t,this.enabled=i,this.debug=s,this.locale=c,this.notifications$={},this.enabled){this.MessageDef.AllDefinitions.forEach((function(e){u.notifications$[e.endpoint]=new o.Subject}));var l={skipNegotiation:!0,transport:r.HttpTransportType.WebSockets,logger:s?r.LogLevel.Debug:r.LogLevel.None},g=(new r.HubConnectionBuilder).withUrl(this.hub_url,l);if(a&&(this.log(this.loc("Building SignalR Hub with Automatic Reconnection")),g=g.withAutomaticReconnect(new Array(100).fill(5e3))),this.msgpack){this.log(this.loc("Building SignalR Hub with MessagePack protocol"));var d=require("@microsoft/signalr-protocol-msgpack");g=g.withHubProtocol(new d.MessagePackHubProtocol)}this.connection=g.build(),this.connect()}else this.log(this.loc("SignalR won't be enabled as per configuration"))}return e.prototype.connect=function(){var e=this;this.connection.start().catch((function(e){return console.log(e)})),this.MessageDef.AllDefinitions.forEach((function(n){null!==n.inTypeDefault&&null===n.outTypeDefault?e.connection.on(n.endpoint,(function(t){e.log(e.loc("Request received from the server for endpoint")+" '"+n.endpoint+"': "+e.substringLog(JSON.stringify(t))),e.notifications$[n.endpoint].next(t)})):e.log(e.loc("Refusing to register endpoint")+" "+n.endpoint+" "+e.loc("because it is not declared as IN - ONLY"))}))},e.prototype.ensureConnected=function(){var e=this;return this.connection.state==t.HubConnectionState.Disconnected?(this.log(this.loc("Connection lost or missing, reconnecting...")),this.connection.start().then((function(e){return Promise.resolve("OK")}),(function(n){return e.log(e.loc("Cannot reconnect SignalR, frontend HUB offline")),Promise.resolve("KO")}))):this.connection.state==t.HubConnectionState.Connected?Promise.resolve("OK"):Promise.resolve("NO-OP")},e.prototype.send=function(e,n){var i=this;if(!this.enabled)return this.log(this.loc("Send request ignored because SignalR is not active by configuration")),o.EMPTY;this.connection.state==t.HubConnectionState.Connecting||this.connection.state==t.HubConnectionState.Reconnecting||this.connection.state==t.HubConnectionState.Disconnecting?(this.log(this.loc("Send request sent before a connection was in stable State, waiting 1 second and retrying")),setTimeout((function(){i.send(e,n)}),1e3)):this.connection.state==t.HubConnectionState.Disconnected?this.ensureConnected().then((function(t){"KO"==t?i.log(i.loc("ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST")):i.send(e,n)})):this.connection.send(e.endpoint,n).then((function(t){i.debug&&console.info(i.loc("Request sent to server")+" - "+e.endpoint+": "+i.substringLog(JSON.stringify(n)))}))},e.prototype.invoke=function(e,n){var s=this;return this.enabled?this.connection.state==t.HubConnectionState.Connecting||this.connection.state==t.HubConnectionState.Reconnecting||this.connection.state==t.HubConnectionState.Disconnecting?(this.log(this.loc("Invoke request sent before a connection was in stable State, waiting 1 second and retrying")),o.of().pipe(i.delay(1e3),i.concatMap((function(){return s.invoke(e,n)})))):this.connection.state==t.HubConnectionState.Disconnected?o.from(this.ensureConnected()).pipe(i.concatMap((function(t){return"KO"==t?(s.log(s.loc("ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST")),o.EMPTY):s.invoke(e,n)}))):o.from(this.connection.invoke(e.endpoint,n)).pipe(i.tap((function(){s.debug&&console.log(s.loc("Request invoked to server")+" - "+e.endpoint+": "+s.substringLog(JSON.stringify(n)))}))):(this.log(this.loc("Invoke request ignored because SignalR is not active by configuration")),o.EMPTY)},e.prototype.observe=function(e){return this.enabled?(this.log(this.loc("Returning observable for required endpoint")+": "+e.endpoint),this.notifications$[e.endpoint]):(this.log(this.loc("Observe request ignored because SignalR is not active by configuration")),o.EMPTY)},e.prototype.disconnect=function(){var e=this;return this.enabled?o.from(this.connection.stop()).pipe(i.catchError((function(e,n){return console.log(e),o.of(null)})),i.tap((function(){e.log(e.loc("Disconnection request honored"))}))):(this.log(this.loc("Disconnection request ignored because SignalR is not active by configuration")),o.EMPTY)},e.prototype.substringLog=function(e,n){return void 0===n&&(n=120),e.length>n?e.substr(0,n)+"[...]":e},e.prototype.log=function(e){this.debug&&console.log("@signalr-notifications: "+e)},e.prototype.loc=function(e){return p[e]?p[e][this.locale]:(console.warn("Untranslated message: "+e),"")},e}();b.decorators=[{type:n.Injectable}],b.ctorParameters=function(){return[{type:a},{type:String,decorators:[{type:n.Inject,args:[c]}]},{type:Boolean,decorators:[{type:n.Inject,args:[d]}]},{type:Boolean,decorators:[{type:n.Inject,args:[u]}]},{type:Boolean,decorators:[{type:n.Inject,args:[l]}]},{type:Boolean,decorators:[{type:n.Inject,args:[f]}]},{type:String,decorators:[{type:n.Inject,args:[g]}]}]};var v=function(){function e(){}return e.forRoot=function(n){return{ngModule:e,providers:[b,{provide:a,useClass:(null==n?void 0:n.messageService)||a},{provide:c,useValue:null==n?void 0:n.hubUrl},{provide:g,useValue:(null==n?void 0:n.locale)||"it-IT"},{provide:u,useValue:null==(null==n?void 0:n.enabled)||(null==n?void 0:n.enabled)},{provide:l,useValue:null!=(null==n?void 0:n.debugMode)&&(null==n?void 0:n.debugMode)},{provide:d,useValue:null!=(null==n?void 0:n.autoReconnect)&&(null==n?void 0:n.autoReconnect)},{provide:f,useValue:null!=(null==n?void 0:n.useMessagePack)&&(null==n?void 0:n.useMessagePack)}]}},e}();v.decorators=[{type:n.NgModule}];var h=function(){function e(e,n,t){this.endpoint=e,this.inTypeDefault=n,this.outTypeDefault=t}return e.In=function(n,t){return new e(n,t,void 0)},e.Out=function(n,t){return new e(n,void 0,t)},e.Bi=function(n,t,o){return new e(n,t,o)},e}(),S=function(){};e.BaseMessageService=a,e.EndpointDef=h,e.NotificationsService=b,e.SignalrNotificationsModule=v,e.SignalrNotificationsModuleConfig=S,e["ɵa"]=c,e["ɵb"]=u,e["ɵc"]=l,e["ɵd"]=g,e["ɵe"]=d,e["ɵf"]=f,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/core"),require("@microsoft/signalr"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@esfaenza/signalr-notifications",["exports","@angular/core","@microsoft/signalr","rxjs","rxjs/operators"],n):n(((e="undefined"!=typeof globalThis?globalThis:e||self).esfaenza=e.esfaenza||{},e.esfaenza["signalr-notifications"]={}),e.ng.core,e.signalR,e.rxjs,e.rxjs.operators)}(this,(function(e,n,t,o,i){"use strict";function s(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),n.default=e,Object.freeze(n)}var r=s(t),c=function(){function e(){this.definitions=[]}return Object.defineProperty(e.prototype,"AllDefinitions",{get:function(){return this.definitions},enumerable:!1,configurable:!0}),e.prototype.add=function(e){this.definitions.push(e)},e}();c.decorators=[{type:n.Injectable}];var a=new n.InjectionToken("ENDPOINT_URL"),u=new n.InjectionToken("SIGNALR_ENABLED"),l=new n.InjectionToken("DEBUG_MODE"),g=new n.InjectionToken("LOCALE"),d=new n.InjectionToken("MESSAGE_PACK"),f=new n.InjectionToken("AUTO_RECONNECT"),p={"Recovering request to Endpoint":{"en-US":"Recovering request to Endpoint","it-IT":"Recupero richiesta verso l'Endpoint"},"Building SignalR Hub with Automatic Reconnection":{"en-US":"Building SignalR Hub with Automatic Reconnection","it-IT":"Compilo l'Hub di SignalR con riconnessione automatica"},"Cannot reconnect SignalR, frontend HUB offline":{"en-US":"Cannot reconnect SignalR, frontend HUB offline","it-IT":"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline"},"Send request sent before a connection was in stable State, waiting 1 second and retrying":{"en-US":"Send request sent before a connection was in stable State, waiting 1 second and retrying","it-IT":"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo"},"Invoke request sent before a connection was in stable State, waiting 1 second and retrying":{"en-US":"Invoke request sent before a connection was in stable State, waiting 1 second and retrying","it-IT":"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo"},"Connection lost or missing, reconnecting...":{"en-US":"Connection lost or missing, reconnecting...","it-IT":"Connessione persa o mancante, mi riconnetto..."},"SignalR won't be enabled as per configuration":{"en-US":"SignalR won't be enabled as per configuration","it-IT":"SignalR non verrà attivato come da configurazione"},"Building SignalR Hub with MessagePack protocol":{"en-US":"Building SignalR Hub with MessagePack protocol","it-IT":"Compilo l'Hub di SignalR con protocollo MessagePack"},"Request received from the server for endpoint":{"en-US":"Request received from the server for endpoint","it-IT":"Richiesta ricevuta dal server per endpoint"},"Refusing to register endpoint":{"en-US":"Refusing to register endpoint","it-IT":"Rifiuto di registrare l'endpoint"},"because it is not declared as IN - ONLY":{"en-US":"because it is not declared as IN - ONLY","it-IT":"in quanto non è registrato solo come IN"},"Send request ignored because SignalR is not active by configuration":{"en-US":"Send request ignored because SignalR is not active by configuration","it-IT":"Richiesta send ignorata in quanto SignalR non è attivo da configurazione"},"Request sent to server":{"en-US":"Request sent to server","it-IT":"Richiesta inviata al server"},"Invoke request ignored because SignalR is not active by configuration":{"en-US":"Invoke request ignored because SignalR is not active by configuration","it-IT":"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione"},"Request invoked to server":{"en-US":"Request invoked to server","it-IT":"Richiesta invoke inviata al server"},"Observe request ignored because SignalR is not active by configuration":{"en-US":"Observe request ignored because SignalR is not active by configuration","it-IT":"Osservazione ignorata in quanto SignalR non è attivo da configurazione"},"Returning observable for required endpoint":{"en-US":"Returning observable for required endpoint","it-IT":"Restituisco l'observable per l'endpoint richiesto"},"Disconnection request ignored because SignalR is not active by configuration":{"en-US":"Disconnection request ignored because SignalR is not active by configuration","it-IT":"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione"},"Disconnection request honored":{"en-US":"Returning observable for required endpoint","it-IT":"Restituito observable per l'endpoint richiesto"},"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST":{"en-US":"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST","it-IT":"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO"}},v=function(){function e(e,n,t,i,s,c,a){var u=this;if(this.MessageDef=e,this.endpoint_url=n,this.msgpack=t,this.enabled=i,this.debug=s,this.locale=a,this.notifications$={},this.RequestsToRecover=[],this.enabled){this.MessageDef.AllDefinitions.forEach((function(e){u.notifications$[e.endpoint]=new o.Subject}));var l={skipNegotiation:!0,transport:r.HttpTransportType.WebSockets,logger:s?r.LogLevel.Debug:r.LogLevel.None},g=(new r.HubConnectionBuilder).withUrl("/"+this.endpoint_url,l);if(c&&(this.log(this.loc("Building SignalR Hub with Automatic Reconnection")),g=g.withAutomaticReconnect(new Array(100).fill(5e3))),this.msgpack){this.log(this.loc("Building SignalR Hub with MessagePack protocol"));var d=require("@microsoft/signalr-protocol-msgpack");g=g.withHubProtocol(new d.MessagePackHubProtocol)}this.connection=g.build(),this.connect((function(){if(0!=u.RequestsToRecover.length){for(var e=0;e<u.RequestsToRecover.length;e++)u.log(u.loc("Recovering request to Endpoint")+" "+u.RequestsToRecover[e].item.endpoint),u.send(u.RequestsToRecover[e].item,u.RequestsToRecover[e].dto);u.RequestsToRecover=[]}}))}else this.log(this.loc("SignalR won't be enabled as per configuration"))}return e.prototype.connect=function(e){var n=this;this.connection.start().catch((function(e){return console.log(e)})).then((function(n){return null==e?void 0:e()})),this.MessageDef.AllDefinitions.forEach((function(e){null!==e.inTypeDefault&&null===e.outTypeDefault?n.connection.on(e.endpoint,(function(t){n.log(n.loc("Request received from the server for endpoint")+" '"+e.endpoint+"': "+n.substringLog(JSON.stringify(t))),n.notifications$[e.endpoint].next(t)})):n.log(n.loc("Refusing to register endpoint")+" "+e.endpoint+" "+n.loc("because it is not declared as IN - ONLY"))}))},e.prototype.ensureConnected=function(){var e=this;return this.connection.state==t.HubConnectionState.Disconnected?(this.log(this.loc("Connection lost or missing, reconnecting...")),this.connection.start().then((function(e){return Promise.resolve("OK")}),(function(n){return e.log(e.loc("Cannot reconnect SignalR, frontend HUB offline")),Promise.resolve("KO")}))):this.connection.state==t.HubConnectionState.Connected?Promise.resolve("OK"):Promise.resolve("NO-OP")},e.prototype.send=function(e,n){var i=this;if(this.connection)return this.enabled?void(this.connection.state==t.HubConnectionState.Connecting||this.connection.state==t.HubConnectionState.Reconnecting||this.connection.state==t.HubConnectionState.Disconnecting?(this.log(this.loc("Send request sent before a connection was in stable State, waiting 1 second and retrying")),setTimeout((function(){i.send(e,n)}),1e3)):this.connection.state==t.HubConnectionState.Disconnected?this.ensureConnected().then((function(t){"KO"==t?i.log(i.loc("ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST")):i.send(e,n)})):this.connection.send(e.endpoint,n).then((function(t){i.debug&&console.info(i.loc("Request sent to server")+" - "+e.endpoint+": "+i.substringLog(JSON.stringify(n)))}))):(this.log(this.loc("Send request ignored because SignalR is not active by configuration")),o.EMPTY);this.RequestsToRecover.push({item:e,dto:n})},e.prototype.invoke=function(e,n){var s=this;return this.enabled?this.connection.state==t.HubConnectionState.Connecting||this.connection.state==t.HubConnectionState.Reconnecting||this.connection.state==t.HubConnectionState.Disconnecting?(this.log(this.loc("Invoke request sent before a connection was in stable State, waiting 1 second and retrying")),o.of().pipe(i.delay(1e3),i.concatMap((function(){return s.invoke(e,n)})))):this.connection.state==t.HubConnectionState.Disconnected?o.from(this.ensureConnected()).pipe(i.concatMap((function(t){return"KO"==t?(s.log(s.loc("ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST")),o.EMPTY):s.invoke(e,n)}))):o.from(this.connection.invoke(e.endpoint,n)).pipe(i.tap((function(){s.debug&&console.log(s.loc("Request invoked to server")+" - "+e.endpoint+": "+s.substringLog(JSON.stringify(n)))}))):(this.log(this.loc("Invoke request ignored because SignalR is not active by configuration")),o.EMPTY)},e.prototype.observe=function(e){return this.enabled?(this.log(this.loc("Returning observable for required endpoint")+": "+e.endpoint),this.notifications$[e.endpoint]):(this.log(this.loc("Observe request ignored because SignalR is not active by configuration")),o.EMPTY)},e.prototype.disconnect=function(){var e=this;return this.enabled?o.from(this.connection.stop()).pipe(i.catchError((function(e,n){return console.log(e),o.of(null)})),i.tap((function(){e.log(e.loc("Disconnection request honored"))}))):(this.log(this.loc("Disconnection request ignored because SignalR is not active by configuration")),o.EMPTY)},e.prototype.substringLog=function(e,n){return void 0===n&&(n=120),e.length>n?e.substr(0,n)+"[...]":e},e.prototype.log=function(e){this.debug&&console.log("@signalr-notifications: "+e)},e.prototype.loc=function(e){return p[e]?p[e][this.locale]:(console.warn("Untranslated message: "+e),"")},e}();v.decorators=[{type:n.Injectable}],v.ctorParameters=function(){return[{type:c},{type:String,decorators:[{type:n.Inject,args:[a]}]},{type:Boolean,decorators:[{type:n.Inject,args:[d]}]},{type:Boolean,decorators:[{type:n.Inject,args:[u]}]},{type:Boolean,decorators:[{type:n.Inject,args:[l]}]},{type:Boolean,decorators:[{type:n.Inject,args:[f]}]},{type:String,decorators:[{type:n.Inject,args:[g]}]}]};var b=function(){function e(){}return e.forRoot=function(n){return{ngModule:e,providers:[v,{provide:c,useClass:(null==n?void 0:n.messageService)||c},{provide:a,useValue:null==n?void 0:n.endpointUrl},{provide:g,useValue:(null==n?void 0:n.locale)||"it-IT"},{provide:u,useValue:null==(null==n?void 0:n.enabled)||(null==n?void 0:n.enabled)},{provide:l,useValue:null!=(null==n?void 0:n.debugMode)&&(null==n?void 0:n.debugMode)},{provide:d,useValue:null!=(null==n?void 0:n.autoReconnect)&&(null==n?void 0:n.autoReconnect)},{provide:f,useValue:null!=(null==n?void 0:n.useMessagePack)&&(null==n?void 0:n.useMessagePack)}]}},e}();b.decorators=[{type:n.NgModule}];var h=function(){function e(e,n,t){this.endpoint=e,this.inTypeDefault=n,this.outTypeDefault=t}return e.In=function(n,t){return new e(n,t,void 0)},e.Out=function(n,t){return new e(n,void 0,t)},e.Bi=function(n,t,o){return new e(n,t,o)},e}(),R=function(){};e.BaseMessageService=c,e.EndpointDef=h,e.NotificationsService=v,e.SignalrNotificationsModule=b,e.SignalrNotificationsModuleConfig=R,e["ɵa"]=a,e["ɵb"]=u,e["ɵc"]=l,e["ɵd"]=g,e["ɵe"]=d,e["ɵf"]=f,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=esfaenza-signalr-notifications.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../projects/signalr-notifications/src/lib/models/BaseMessageService.ts","../../../projects/signalr-notifications/src/lib/tokens.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.loc.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.module.ts","../../../projects/signalr-notifications/src/lib/models/EndpointDef.ts","../../../projects/signalr-notifications/src/lib/config/SignalrNotificationsModuleConfig.ts"],"names":["BaseMessageService","this","definitions","Object","defineProperty","prototype","add","endpoint","push","Injectable","HUB_URL","InjectionToken","SIGNALR_ENABLED","DEBUG_MODE","LOCALE","MESSAGE_PACK","AUTO_RECONNECT","Loc","Building SignalR Hub with Automatic Reconnection","en-US","it-IT","Cannot reconnect SignalR, frontend HUB offline","Send request sent before a connection was in stable State, waiting 1 second and retrying","Invoke request sent before a connection was in stable State, waiting 1 second and retrying","Connection lost or missing, reconnecting...","SignalR won't be enabled as per configuration","Building SignalR Hub with MessagePack protocol","Request received from the server for endpoint","Refusing to register endpoint","because it is not declared as IN - ONLY","Send request ignored because SignalR is not active by configuration","Request sent to server","Invoke request ignored because SignalR is not active by configuration","Request invoked to server","Observe request ignored because SignalR is not active by configuration","Returning observable for required endpoint","Disconnection request ignored because SignalR is not active by configuration","Disconnection request honored","ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST","NotificationsService","MessageDef","hub_url","msgpack","enabled","debug","autoreconnect","locale","_this","notifications$","AllDefinitions","forEach","def","Subject","pars","skipNegotiation","transport","signalR","HttpTransportType","WebSockets","logger","LogLevel","Debug","None","builder","HubConnectionBuilder","withUrl","log","loc","withAutomaticReconnect","Array","fill","mphpModule","require","withHubProtocol","MessagePackHubProtocol","connection","build","connect","start","catch","err","console","d","inTypeDefault","outTypeDefault","on","message","substringLog","JSON","stringify","next","ensureConnected","state","HubConnectionState","Disconnected","then","_","Promise","resolve","Connected","send","item","dto","EMPTY","Connecting","Reconnecting","Disconnecting","setTimeout","t","info","invoke","of","pipe","delay","concatMap","from","res","tap","observe","disconnect","stop","catchError","caught","text","maxchars","length","substr","warn","Inject","args","SignalrNotificationsModule","forRoot","config","ngModule","providers","provide","useClass","messageService","useValue","hubUrl","debugMode","autoReconnect","useMessagePack","NgModule","EndpointDef","In","name","undefined","Out","Bi"],"mappings":"g1BASA,SAAAA,IAGYC,KAAAC,YAAuC,UA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CAAEJ,QAASzH,EAAQ4H,UAAUN,MAAAA,OAAM,EAANA,EAAQtF,SAAU,SAC/C,CAAEyF,QAAS3H,EAAiB8H,SAA6B,OAAnBN,MAAAA,OAAM,EAANA,EAAQzF,WAAkByF,MAAAA,OAAM,EAANA,EAAQzF,UACxE,CAAE4F,QAAS1H,EAAY6H,SAA+B,OAArBN,MAAAA,OAAM,EAANA,EAAQQ,aAAoBR,MAAAA,OAAM,EAANA,EAAQQ,YACrE,CAAEL,QAASxH,EAAc2H,SAAmC,OAAzBN,MAAAA,OAAM,EAANA,EAAQS,iBAAwBT,MAAAA,OAAM,EAANA,EAAQS,gBAC3E,CAAEN,QAASvH,EAAgB0H,SAAoC,OAA1BN,MAAAA,OAAM,EAANA,EAAQU,kBAAyBV,MAAAA,OAAM,EAANA,EAAQU,6CAbrFC,EAAAA,4BCKG,SAAAC,EAAmBzI,EAAyB4E,EAA2BC,GAApDnF,KAAAM,SAAAA,EAAyBN,KAAAkF,cAAAA,EAA2BlF,KAAAmF,eAAAA,SAIzD4D,EAAAC,GAAP,SAAeC,EAAc/D,GAChC,OAAO,IAAI6D,EAAuBE,EAAM/D,OAAegE,IAI7CH,EAAAI,IAAP,SAAiBF,EAAc9D,GAClC,OAAO,IAAI4D,EAAwBE,OAAMC,EAAW/D,IAI1C4D,EAAAK,GAAP,SAAqBH,EAAc/D,EAAoBC,GAC1D,OAAO,IAAI4D,EAAuBE,EAAM/D,EAAeC,WClB/D","sourcesContent":["// Angular\r\nimport { Injectable } from '@angular/core';\r\n\r\n// Modelli\r\nimport { EndpointDef } from './EndpointDef';\r\n\r\n/**\r\n * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione\r\n */\r\n@Injectable()\r\nexport class BaseMessageService {\r\n\r\n private definitions: EndpointDef<any, any>[] = [];\r\n\r\n /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */\r\n public get AllDefinitions(): EndpointDef<any, any>[] { return this.definitions; }\r\n\r\n public add(endpoint: EndpointDef<any, any>) {\r\n this.definitions.push(endpoint);\r\n }\r\n}","import { InjectionToken } from '@angular/core';\r\n\r\n/**\r\n * Hub a cui collegarsi\r\n */\r\nexport const HUB_URL: InjectionToken<string> = new InjectionToken<string>('HUB_URL');\r\n\r\n/**\r\n * Indica se la libreria dev'essere attiva o no\r\n */\r\nexport const SIGNALR_ENABLED: InjectionToken<string> = new InjectionToken<boolean>('SIGNALR_ENABLED');\r\n\r\n/**\r\n * Indica se stampare messaggi di debug in console\r\n */\r\nexport const DEBUG_MODE: InjectionToken<string> = new InjectionToken<boolean>('DEBUG_MODE');\r\n\r\n/**\r\n * Indica il locale utilizzato dalla libreria per i messaggi. Sono supportati \"it-IT\" ed \"en-US\"\r\n */\r\nexport const LOCALE: InjectionToken<string> = new InjectionToken<string>('LOCALE');\r\n\r\n/**\r\n * Indica se utilizzare il protocollo di trasferimento \"MessagePack\"\r\n */\r\nexport const MESSAGE_PACK: InjectionToken<boolean> = new InjectionToken<boolean>('MESSAGE_PACK');\r\n\r\n/**\r\n * Indica se tentare in automatico la riconnessione\r\n */\r\nexport const AUTO_RECONNECT: InjectionToken<boolean> = new InjectionToken<boolean>('AUTO_RECONNECT');","/**\r\n * Oggetto statico di localizzazione per i messaggi scritti dal servizio\r\n */\r\nexport const Loc ={\r\n \"Building SignalR Hub with Automatic Reconnection\": { \"en-US\": \"Building SignalR Hub with Automatic Reconnection\", \"it-IT\": \"Compilo l'Hub di SignalR con riconnessione automatica\", },\r\n \"Cannot reconnect SignalR, frontend HUB offline\": { \"en-US\": \"Cannot reconnect SignalR, frontend HUB offline\", \"it-IT\": \"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline\", },\r\n \"Send request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Send request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Connection lost or missing, reconnecting...\" : { \"en-US\": \"Connection lost or missing, reconnecting...\", \"it-IT\": \"Connessione persa o mancante, mi riconnetto...\", },\r\n \"SignalR won't be enabled as per configuration\": { \"en-US\": \"SignalR won't be enabled as per configuration\", \"it-IT\": \"SignalR non verrà attivato come da configurazione\", },\r\n \"Building SignalR Hub with MessagePack protocol\": { \"en-US\": \"Building SignalR Hub with MessagePack protocol\", \"it-IT\": \"Compilo l'Hub di SignalR con protocollo MessagePack\", },\r\n \"Request received from the server for endpoint\": { \"en-US\": \"Request received from the server for endpoint\", \"it-IT\": \"Richiesta ricevuta dal server per endpoint\", },\r\n \"Refusing to register endpoint\": { \"en-US\": \"Refusing to register endpoint\", \"it-IT\": \"Rifiuto di registrare l'endpoint\", },\r\n \"because it is not declared as IN - ONLY\": { \"en-US\": \"because it is not declared as IN - ONLY\", \"it-IT\": \"in quanto non è registrato solo come IN\", },\r\n \"Send request ignored because SignalR is not active by configuration\": { \"en-US\": \"Send request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta send ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request sent to server\": { \"en-US\": \"Request sent to server\", \"it-IT\": \"Richiesta inviata al server\", },\r\n \"Invoke request ignored because SignalR is not active by configuration\": { \"en-US\": \"Invoke request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request invoked to server\": { \"en-US\": \"Request invoked to server\", \"it-IT\": \"Richiesta invoke inviata al server\", },\r\n \"Observe request ignored because SignalR is not active by configuration\": { \"en-US\": \"Observe request ignored because SignalR is not active by configuration\", \"it-IT\": \"Osservazione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Returning observable for required endpoint\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituisco l'observable per l'endpoint richiesto\", },\r\n \"Disconnection request ignored because SignalR is not active by configuration\": { \"en-US\": \"Disconnection request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Disconnection request honored\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituito observable per l'endpoint richiesto\", },\r\n \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\": { \"en-US\": \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\", \"it-IT\": \"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO\"}\r\n}","// Angular\r\nimport { Injectable, Inject } from \"@angular/core\";\r\n\r\n// Direttive, Componenti, Librerie\r\nimport * as signalR from '@microsoft/signalr';\r\nimport { HubConnectionState } from \"@microsoft/signalr\";\r\nimport { Observable, Subject, EMPTY, from, of } from \"rxjs\";\r\nimport { catchError, concatMap, delay, tap } from \"rxjs/operators\";\r\n\r\n// Modelli\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { EndpointDef } from './models/EndpointDef';\r\nimport { DEBUG_MODE, HUB_URL, LOCALE, MESSAGE_PACK, SIGNALR_ENABLED, AUTO_RECONNECT } from \"./tokens\";\r\n\r\n// Localizzazione\r\nimport { Loc } from './signalr-notifications.service.loc';\r\n\r\n/**\r\n * Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione\r\n */\r\n@Injectable()\r\nexport class NotificationsService {\r\n\r\n /**\r\n * Cache degli Observable generati in base agli Endpoint disponibili\r\n */\r\n private notifications$: { [index: string]: Subject<any> } = {};\r\n\r\n /**\r\n * Connessione Signalr\r\n */\r\n private connection: signalR.HubConnection;\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @ignore\r\n */\r\n constructor(private MessageDef: BaseMessageService, @Inject(HUB_URL) private hub_url: string, @Inject(MESSAGE_PACK) private msgpack: boolean, @Inject(SIGNALR_ENABLED) private enabled: boolean, @Inject(DEBUG_MODE) private debug: boolean, @Inject(AUTO_RECONNECT) autoreconnect: boolean, @Inject(LOCALE) private locale : string) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"SignalR won't be enabled as per configuration\"));\r\n return;\r\n }\r\n\r\n this.MessageDef.AllDefinitions.forEach(def => { this.notifications$[def.endpoint] = new Subject<typeof def.inTypeDefault>(); });\r\n\r\n let pars: signalR.IHttpConnectionOptions = { skipNegotiation: true, transport: signalR.HttpTransportType.WebSockets, logger: debug ? signalR.LogLevel.Debug : signalR.LogLevel.None };\r\n var builder = new signalR.HubConnectionBuilder().withUrl(this.hub_url, pars);\r\n\r\n if (autoreconnect) {\r\n this.log(this.loc(\"Building SignalR Hub with Automatic Reconnection\"));\r\n // 100 tentativi di riconnessione, 1 ogni 5 secondi\r\n builder = builder.withAutomaticReconnect(new Array(100).fill(5 * 1000));\r\n }\r\n\r\n if (this.msgpack) {\r\n this.log(this.loc(\"Building SignalR Hub with MessagePack protocol\"));\r\n var mphpModule = require(\"@microsoft/signalr-protocol-msgpack\");\r\n builder = builder.withHubProtocol(new mphpModule.MessagePackHubProtocol())\r\n }\r\n\r\n this.connection = builder.build();\r\n this.connect();\r\n }\r\n\r\n /**\r\n * Effettua la connessione all'Hub Signalr e registra tutti gli Endpoint per cui il Backend comunica con il Frontend sulla **connection**\r\n */\r\n private connect() {\r\n this.connection.start().catch(err => console.log(err));\r\n this.MessageDef.AllDefinitions.forEach(d => {\r\n //Registro solo le cose di IN, quelle di out sono chiamate che faccio io al BE quindi non servono\r\n if (d.inTypeDefault !== null && d.outTypeDefault === null)\r\n this.connection.on(d.endpoint, (message) => {\r\n this.log(this.loc(\"Request received from the server for endpoint\") + \" '\" + d.endpoint + \"': \" + this.substringLog(JSON.stringify(message)));\r\n this.notifications$[d.endpoint].next(message);\r\n });\r\n else\r\n this.log(this.loc(\"Refusing to register endpoint\") + \" \" + d.endpoint + \" \" + this.loc(\"because it is not declared as IN - ONLY\"));\r\n });\r\n }\r\n\r\n /**\r\n * Effettua verifiche sulla connessione e, in caso non fosse collegata, tenta di riconnetterla\r\n * \r\n * @returns {Promise<'OK' | 'KO' | 'NO-OP'>} 'OK' Se la connessione è già connessa o è stata riconnessa con successo, 'KO' Se non è stato possibile riconnettere \r\n * una connessione disconnessa, 'NO-OP' se la connesisone è in uno stato intermedio che non può essere modificato\r\n */\r\n public ensureConnected(): Promise<'OK' | 'KO' | 'NO-OP'> {\r\n if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.log(this.loc(\"Connection lost or missing, reconnecting...\"));\r\n\r\n return this.connection.start()\r\n .then(_ => {\r\n return Promise.resolve(\"OK\");\r\n }, _ => {\r\n this.log(this.loc(\"Cannot reconnect SignalR, frontend HUB offline\"));\r\n return Promise.resolve(\"KO\");\r\n });\r\n }\r\n else if (this.connection.state == HubConnectionState.Connected)\r\n return Promise.resolve(\"OK\");\r\n else\r\n return Promise.resolve(\"NO-OP\");\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend\r\n * \r\n * @param {EndpointDef<TOut, any>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n */\r\n public send<TOut>(item: EndpointDef<TOut, any>, dto: TOut) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Send request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Send request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n setTimeout(() => { this.send(item, dto); }, 1000);\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.ensureConnected().then(t => {\r\n if (t == \"KO\") this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n else this.send(item, dto);\r\n })\r\n }\r\n else {\r\n this.connection.send(item.endpoint, dto).then(_ => {\r\n if (this.debug)\r\n console.info(this.loc(\"Request sent to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend, aspettandosi una risposta\r\n * \r\n * @param {EndpointDef<TOut, TIn>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere il risultato della chiamata\r\n */\r\n public invoke<TOut, TIn>(item: EndpointDef<TOut, TIn>, dto: TOut): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Invoke request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n return of().pipe(delay(1000), concatMap(() => this.invoke(item, dto)));\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n return from(this.ensureConnected()).pipe(concatMap((res) => {\r\n if (res == \"KO\") {\r\n this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n return EMPTY;\r\n }\r\n else return this.invoke(item, dto);\r\n }))\r\n }\r\n else {\r\n return from(this.connection.invoke<TIn>(item.endpoint, dto)).pipe(\r\n tap(() => {\r\n if (this.debug) console.log(this.loc(\"Request invoked to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n })\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Hook per osservare i dati spediti ad un Endpoint dal Backend\r\n * \r\n * @param {EndpointDef<TIn, any>} item Endpoint su cui ascoltare\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere l'oggetto generato ad ogni chiamata dal Backend al Frontend\r\n */\r\n public observe<TIn>(item: EndpointDef<TIn, any>): Observable<TIn> {\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Observe request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n this.log(this.loc(\"Returning observable for required endpoint\") + \": \" + item.endpoint);\r\n return <Observable<TIn>>this.notifications$[item.endpoint];\r\n }\r\n\r\n /**\r\n * Disconnessione del sistema di SignalR\r\n * \r\n * @returns {Observable<void>} Observable a cui registrarsi che viene chiamato quando la disconnessione è terminata\r\n */\r\n public disconnect(): Observable<void> {\r\n //NO-OP se non attivo\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Disconnection request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n return from(this.connection.stop()).pipe(\r\n catchError((err, caught) => { console.log(err); return of(null); }),\r\n tap(() => {\r\n this.log(this.loc(\"Disconnection request honored\"));\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Taglia un log troppo lungo\r\n * \r\n * @param {string} text Log da tagliare\r\n * @param {number} maxchars Numero massimo di caratteri da tenere\r\n * \r\n * @returns {string} Log tagliato\r\n */\r\n private substringLog(text: string, maxchars: number = 120) : string {\r\n return text.length > maxchars ? text.substr(0, maxchars) + \"[...]\" : text;\r\n }\r\n\r\n /**\r\n * Stampa un log a console\r\n * \r\n * @param {string} message Messaggio da stampare\r\n */\r\n private log(message: string) {\r\n if (this.debug)\r\n console.log(\"@signalr-notifications: \" + message)\r\n }\r\n\r\n /**\r\n * Helper di localizzazione\r\n * \r\n * @param {string} message Messaggio da tradurre\r\n * \r\n * @returns {string} Messaggio tradotto\r\n */\r\n private loc(message: string) : string{\r\n if(!Loc[message])\r\n {\r\n console.warn(\"Untranslated message: \" + message)\r\n return \"\";\r\n }\r\n return Loc[message][this.locale];\r\n }\r\n}","\r\nimport { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { SignalrNotificationsModuleConfig } from './config/SignalrNotificationsModuleConfig';\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { NotificationsService } from './signalr-notifications.service';\r\nimport { HUB_URL, SIGNALR_ENABLED, DEBUG_MODE, LOCALE, MESSAGE_PACK, AUTO_RECONNECT } from './tokens';\r\n\r\n@NgModule()\r\nexport class SignalrNotificationsModule {\r\n static forRoot(config?: SignalrNotificationsModuleConfig): ModuleWithProviders<SignalrNotificationsModule> {\r\n return {\r\n ngModule: SignalrNotificationsModule,\r\n providers: [\r\n NotificationsService,\r\n { provide: BaseMessageService, useClass: config?.messageService || BaseMessageService },\r\n { provide: HUB_URL, useValue: config?.hubUrl },\r\n { provide: LOCALE, useValue: config?.locale || 'it-IT' },\r\n { provide: SIGNALR_ENABLED, useValue: config?.enabled != null ? config?.enabled : true },\r\n { provide: DEBUG_MODE, useValue: config?.debugMode != null ? config?.debugMode : false },\r\n { provide: MESSAGE_PACK, useValue: config?.autoReconnect != null ? config?.autoReconnect : false },\r\n { provide: AUTO_RECONNECT, useValue: config?.useMessagePack != null ? config?.useMessagePack : false },\r\n ]\r\n };\r\n }\r\n}","/**\r\n * Definisce un Endpoint che spedisce un'informazione di tipo TIn e restituisce un'informazione di tipo TOut\r\n */\r\nexport class EndpointDef<TIn, TOut> {\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @param {string} endpoint Nome del metodo da chiamare nell'Hub del Backend contattato\r\n * @param {TIn} inTypeDefault Default per il tipo TIn. Utilizzato per fare Typecheck sulle chiamate da Backend a Frontend\r\n * @param {TOut} outTypeDefault Default per il tipo TOut. Utilizzato per fare Typecheck sulle chiamate da Frontend a Backend\r\n */\r\n constructor(public endpoint: string, public inTypeDefault: TIn, public outTypeDefault: TOut) { }\r\n\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo INPUT */\r\n public static In<TIn>(name: string, inTypeDefault: TIn): EndpointDef<TIn, void> {\r\n return new EndpointDef<TIn, void>(name, inTypeDefault, undefined);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */\r\n public static Out<TOut>(name: string, outTypeDefault: TOut): EndpointDef<void, TOut> {\r\n return new EndpointDef<void, TOut>(name, undefined, outTypeDefault);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */\r\n public static Bi<TIn, TOut>(name: string, inTypeDefault: TIn, outTypeDefault: TOut): EndpointDef<TIn, TOut> {\r\n return new EndpointDef<TIn, TOut>(name, inTypeDefault, outTypeDefault);\r\n }\r\n}","// Angular\r\nimport { Type } from '@angular/core';\r\n\r\n// Modelli\r\nimport { BaseMessageService } from '../models/BaseMessageService';\r\n\r\n/**\r\n * Classe di configurazione per la libreria\r\n */\r\nexport class SignalrNotificationsModuleConfig {\r\n\r\n /**\r\n * Url nei confronti del quale aprire la connessione SignalR\r\n */\r\n hubUrl : string;\r\n\r\n /**\r\n * Servizio che definisce i messaggi di IN e OUT coi loro default\r\n */\r\n messageService? : Type<BaseMessageService>;\r\n\r\n /**\r\n * Indica se abilitare o meno la connessione SignalR nei confronti dell'URL **hubUrl**\r\n */\r\n enabled? : boolean;\r\n\r\n /**\r\n * Indica se utilizzare message pack come protocollo di trasmissione\r\n */\r\n useMessagePack? : boolean;\r\n\r\n /**\r\n * Indica se tentare di riconnettersi automaticamente quando la connessione cade\r\n */\r\n autoReconnect? : boolean;\r\n\r\n /**\r\n * Indica se scrivere o meno i messaggi di debug\r\n */\r\n debugMode? : boolean;\r\n\r\n /**\r\n * Lingua dei feedback a console, sono supportati 'it-IT' ed 'en-US'\r\n */\r\n locale? : string\r\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../../projects/signalr-notifications/src/lib/models/BaseMessageService.ts","../../../projects/signalr-notifications/src/lib/tokens.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.loc.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.module.ts","../../../projects/signalr-notifications/src/lib/models/EndpointDef.ts","../../../projects/signalr-notifications/src/lib/config/SignalrNotificationsModuleConfig.ts"],"names":["BaseMessageService","this","definitions","Object","defineProperty","prototype","add","endpoint","push","Injectable","ENDPOINT_URL","InjectionToken","SIGNALR_ENABLED","DEBUG_MODE","LOCALE","MESSAGE_PACK","AUTO_RECONNECT","Loc","Recovering request to Endpoint","en-US","it-IT","Building SignalR Hub with Automatic Reconnection","Cannot reconnect SignalR, frontend HUB offline","Send request sent before a connection was in stable State, waiting 1 second and retrying","Invoke request sent before a connection was in stable State, waiting 1 second and retrying","Connection lost or missing, reconnecting...","SignalR won't be enabled as per configuration","Building SignalR Hub with MessagePack protocol","Request received from the server for endpoint","Refusing to register endpoint","because it is not declared as IN - ONLY","Send request ignored because SignalR is not active by configuration","Request sent to server","Invoke request ignored because SignalR is not active by configuration","Request invoked to server","Observe request ignored because SignalR is not active by configuration","Returning observable for required endpoint","Disconnection request ignored because SignalR is not active by configuration","Disconnection request honored","ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST","NotificationsService","MessageDef","endpoint_url","msgpack","enabled","debug","autoreconnect","locale","_this","notifications$","RequestsToRecover","AllDefinitions","forEach","def","Subject","pars","skipNegotiation","transport","signalR","HttpTransportType","WebSockets","logger","LogLevel","Debug","None","builder","HubConnectionBuilder","withUrl","log","loc","withAutomaticReconnect","Array","fill","mphpModule","require","withHubProtocol","MessagePackHubProtocol","connection","build","connect","length","i","item","send","dto","onConnected","start","catch","err","console","then","_","d","inTypeDefault","outTypeDefault","on","message","substringLog","JSON","stringify","next","ensureConnected","state","HubConnectionState","Disconnected","Promise","resolve","Connected","Connecting","Reconnecting","Disconnecting","setTimeout","t","info","EMPTY","invoke","of","pipe","delay","concatMap","from","res","tap","observe","disconnect","stop","catchError","caught","text","maxchars","substr","warn","Inject","args","SignalrNotificationsModule","forRoot","config","ngModule","providers","provide","useClass","messageService","useValue","endpointUrl","debugMode","autoReconnect","useMessagePack","NgModule","EndpointDef","In","name","undefined","Out","Bi"],"mappings":"g1BASA,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,EAAAC,GAAP,SAAeC,EAAczD,GAChC,OAAO,IAAIuD,EAAuBE,EAAMzD,OAAe0D,IAI7CH,EAAAI,IAAP,SAAiBF,EAAcxD,GAClC,OAAO,IAAIsD,EAAwBE,OAAMC,EAAWzD,IAI1CsD,EAAAK,GAAP,SAAqBH,EAAczD,EAAoBC,GAC1D,OAAO,IAAIsD,EAAuBE,EAAMzD,EAAeC,WClB/D","sourcesContent":["// Angular\r\nimport { Injectable } from '@angular/core';\r\n\r\n// Modelli\r\nimport { EndpointDef } from './EndpointDef';\r\n\r\n/**\r\n * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione\r\n */\r\n@Injectable()\r\nexport class BaseMessageService {\r\n\r\n private definitions: EndpointDef<any, any>[] = [];\r\n\r\n /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */\r\n public get AllDefinitions(): EndpointDef<any, any>[] { return this.definitions; }\r\n\r\n public add(endpoint: EndpointDef<any, any>) {\r\n this.definitions.push(endpoint);\r\n }\r\n}","import { InjectionToken } from '@angular/core';\r\n\r\n/**\r\n * Hub a cui collegarsi\r\n */\r\nexport const ENDPOINT_URL: InjectionToken<string> = new InjectionToken<string>('ENDPOINT_URL');\r\n\r\n/**\r\n * Indica se la libreria dev'essere attiva o no\r\n */\r\nexport const SIGNALR_ENABLED: InjectionToken<string> = new InjectionToken<boolean>('SIGNALR_ENABLED');\r\n\r\n/**\r\n * Indica se stampare messaggi di debug in console\r\n */\r\nexport const DEBUG_MODE: InjectionToken<string> = new InjectionToken<boolean>('DEBUG_MODE');\r\n\r\n/**\r\n * Indica il locale utilizzato dalla libreria per i messaggi. Sono supportati \"it-IT\" ed \"en-US\"\r\n */\r\nexport const LOCALE: InjectionToken<string> = new InjectionToken<string>('LOCALE');\r\n\r\n/**\r\n * Indica se utilizzare il protocollo di trasferimento \"MessagePack\"\r\n */\r\nexport const MESSAGE_PACK: InjectionToken<boolean> = new InjectionToken<boolean>('MESSAGE_PACK');\r\n\r\n/**\r\n * Indica se tentare in automatico la riconnessione\r\n */\r\nexport const AUTO_RECONNECT: InjectionToken<boolean> = new InjectionToken<boolean>('AUTO_RECONNECT');","/**\r\n * Oggetto statico di localizzazione per i messaggi scritti dal servizio\r\n */\r\nexport const Loc ={\r\n \"Recovering request to Endpoint\": {\"en-US\": \"Recovering request to Endpoint\", \"it-IT\": \"Recupero richiesta verso l'Endpoint\"},\r\n \"Building SignalR Hub with Automatic Reconnection\": { \"en-US\": \"Building SignalR Hub with Automatic Reconnection\", \"it-IT\": \"Compilo l'Hub di SignalR con riconnessione automatica\", },\r\n \"Cannot reconnect SignalR, frontend HUB offline\": { \"en-US\": \"Cannot reconnect SignalR, frontend HUB offline\", \"it-IT\": \"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline\", },\r\n \"Send request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Send request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Connection lost or missing, reconnecting...\" : { \"en-US\": \"Connection lost or missing, reconnecting...\", \"it-IT\": \"Connessione persa o mancante, mi riconnetto...\", },\r\n \"SignalR won't be enabled as per configuration\": { \"en-US\": \"SignalR won't be enabled as per configuration\", \"it-IT\": \"SignalR non verrà attivato come da configurazione\", },\r\n \"Building SignalR Hub with MessagePack protocol\": { \"en-US\": \"Building SignalR Hub with MessagePack protocol\", \"it-IT\": \"Compilo l'Hub di SignalR con protocollo MessagePack\", },\r\n \"Request received from the server for endpoint\": { \"en-US\": \"Request received from the server for endpoint\", \"it-IT\": \"Richiesta ricevuta dal server per endpoint\", },\r\n \"Refusing to register endpoint\": { \"en-US\": \"Refusing to register endpoint\", \"it-IT\": \"Rifiuto di registrare l'endpoint\", },\r\n \"because it is not declared as IN - ONLY\": { \"en-US\": \"because it is not declared as IN - ONLY\", \"it-IT\": \"in quanto non è registrato solo come IN\", },\r\n \"Send request ignored because SignalR is not active by configuration\": { \"en-US\": \"Send request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta send ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request sent to server\": { \"en-US\": \"Request sent to server\", \"it-IT\": \"Richiesta inviata al server\", },\r\n \"Invoke request ignored because SignalR is not active by configuration\": { \"en-US\": \"Invoke request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request invoked to server\": { \"en-US\": \"Request invoked to server\", \"it-IT\": \"Richiesta invoke inviata al server\", },\r\n \"Observe request ignored because SignalR is not active by configuration\": { \"en-US\": \"Observe request ignored because SignalR is not active by configuration\", \"it-IT\": \"Osservazione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Returning observable for required endpoint\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituisco l'observable per l'endpoint richiesto\", },\r\n \"Disconnection request ignored because SignalR is not active by configuration\": { \"en-US\": \"Disconnection request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Disconnection request honored\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituito observable per l'endpoint richiesto\", },\r\n \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\": { \"en-US\": \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\", \"it-IT\": \"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO\"}\r\n}","// Angular\r\nimport { Injectable, Inject } from \"@angular/core\";\r\n\r\n// Direttive, Componenti, Librerie\r\nimport * as signalR from '@microsoft/signalr';\r\nimport { HubConnectionState } from \"@microsoft/signalr\";\r\nimport { Observable, Subject, EMPTY, from, of } from \"rxjs\";\r\nimport { catchError, concatMap, delay, tap } from \"rxjs/operators\";\r\n\r\n// Modelli\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { EndpointDef } from './models/EndpointDef';\r\nimport { DEBUG_MODE, ENDPOINT_URL, LOCALE, MESSAGE_PACK, SIGNALR_ENABLED, AUTO_RECONNECT } from \"./tokens\";\r\n\r\n// Localizzazione\r\nimport { Loc } from './signalr-notifications.service.loc';\r\n\r\n/** Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione */\r\n@Injectable()\r\nexport class NotificationsService {\r\n\r\n /** Cache degli Observable generati in base agli Endpoint disponibili */\r\n private notifications$: { [index: string]: Subject<any> } = {};\r\n\r\n /** Connessione Signalr */\r\n private connection: signalR.HubConnection;\r\n\r\n /** Coda di chiamate da recuperare quando la connessione viene finalmente aperta */\r\n private RequestsToRecover: { item: EndpointDef<any, any>, dto: any }[] = [];\r\n\r\n /** @ignore Costruttore */\r\n constructor(private MessageDef: BaseMessageService, @Inject(ENDPOINT_URL) private endpoint_url: string, @Inject(MESSAGE_PACK) private msgpack: boolean, @Inject(SIGNALR_ENABLED) private enabled: boolean, @Inject(DEBUG_MODE) private debug: boolean, @Inject(AUTO_RECONNECT) autoreconnect: boolean, @Inject(LOCALE) private locale: string) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"SignalR won't be enabled as per configuration\"));\r\n return;\r\n }\r\n\r\n this.MessageDef.AllDefinitions.forEach(def => { this.notifications$[def.endpoint] = new Subject<typeof def.inTypeDefault>(); });\r\n\r\n let pars: signalR.IHttpConnectionOptions = { skipNegotiation: true, transport: signalR.HttpTransportType.WebSockets, logger: debug ? signalR.LogLevel.Debug : signalR.LogLevel.None };\r\n var builder = new signalR.HubConnectionBuilder().withUrl(\"/\" + this.endpoint_url, pars);\r\n\r\n if (autoreconnect) {\r\n this.log(this.loc(\"Building SignalR Hub with Automatic Reconnection\"));\r\n // 100 tentativi di riconnessione, 1 ogni 5 secondi\r\n builder = builder.withAutomaticReconnect(new Array(100).fill(5 * 1000));\r\n }\r\n\r\n if (this.msgpack) {\r\n this.log(this.loc(\"Building SignalR Hub with MessagePack protocol\"));\r\n var mphpModule = require(\"@microsoft/signalr-protocol-msgpack\");\r\n builder = builder.withHubProtocol(new mphpModule.MessagePackHubProtocol())\r\n }\r\n\r\n this.connection = builder.build();\r\n this.connect(() => {\r\n if (this.RequestsToRecover.length == 0)\r\n return;\r\n\r\n for (let i = 0; i < this.RequestsToRecover.length; i++) {\r\n this.log(this.loc(\"Recovering request to Endpoint\") + \" \" + this.RequestsToRecover[i].item.endpoint)\r\n this.send(this.RequestsToRecover[i].item, this.RequestsToRecover[i].dto);\r\n }\r\n\r\n this.RequestsToRecover = [];\r\n });\r\n }\r\n\r\n /**\r\n * Effettua la connessione all'Hub Signalr e registra tutti gli Endpoint per cui il Backend comunica con il Frontend sulla **connection**\r\n */\r\n private connect(onConnected?: () => void) {\r\n this.connection.start().catch(err => console.log(err)).then(_ => onConnected?.());\r\n this.MessageDef.AllDefinitions.forEach(d => {\r\n //Registro solo le cose di IN, quelle di out sono chiamate che faccio io al BE quindi non servono\r\n if (d.inTypeDefault !== null && d.outTypeDefault === null)\r\n this.connection.on(d.endpoint, (message) => {\r\n this.log(this.loc(\"Request received from the server for endpoint\") + \" '\" + d.endpoint + \"': \" + this.substringLog(JSON.stringify(message)));\r\n this.notifications$[d.endpoint].next(message);\r\n });\r\n else\r\n this.log(this.loc(\"Refusing to register endpoint\") + \" \" + d.endpoint + \" \" + this.loc(\"because it is not declared as IN - ONLY\"));\r\n });\r\n }\r\n\r\n /**\r\n * Effettua verifiche sulla connessione e, in caso non fosse collegata, tenta di riconnetterla\r\n * \r\n * @returns {Promise<'OK' | 'KO' | 'NO-OP'>} 'OK' Se la connessione è già connessa o è stata riconnessa con successo, 'KO' Se non è stato possibile riconnettere \r\n * una connessione disconnessa, 'NO-OP' se la connesisone è in uno stato intermedio che non può essere modificato\r\n */\r\n public ensureConnected(): Promise<'OK' | 'KO' | 'NO-OP'> {\r\n if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.log(this.loc(\"Connection lost or missing, reconnecting...\"));\r\n\r\n return this.connection.start()\r\n .then(_ => {\r\n return Promise.resolve(\"OK\");\r\n }, _ => {\r\n this.log(this.loc(\"Cannot reconnect SignalR, frontend HUB offline\"));\r\n return Promise.resolve(\"KO\");\r\n });\r\n }\r\n else if (this.connection.state == HubConnectionState.Connected)\r\n return Promise.resolve(\"OK\");\r\n else\r\n return Promise.resolve(\"NO-OP\");\r\n }\r\n\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend\r\n * \r\n * @param {EndpointDef<TOut, any>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n */\r\n public send<TOut>(item: EndpointDef<TOut, any>, dto: TOut) {\r\n if (!this.connection) {\r\n this.RequestsToRecover.push({ item, dto });\r\n return;\r\n }\r\n\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Send request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Send request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n setTimeout(() => { this.send(item, dto); }, 1000);\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.ensureConnected().then(t => {\r\n if (t == \"KO\") this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n else this.send(item, dto);\r\n })\r\n }\r\n else {\r\n this.connection.send(item.endpoint, dto).then(_ => {\r\n if (this.debug)\r\n console.info(this.loc(\"Request sent to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend, aspettandosi una risposta\r\n * \r\n * @param {EndpointDef<TOut, TIn>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere il risultato della chiamata\r\n */\r\n public invoke<TOut, TIn>(item: EndpointDef<TOut, TIn>, dto: TOut): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Invoke request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n return of().pipe(delay(1000), concatMap(() => this.invoke(item, dto)));\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n return from(this.ensureConnected()).pipe(concatMap((res) => {\r\n if (res == \"KO\") {\r\n this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n return EMPTY;\r\n }\r\n else return this.invoke(item, dto);\r\n }))\r\n }\r\n else {\r\n return from(this.connection.invoke<TIn>(item.endpoint, dto)).pipe(\r\n tap(() => {\r\n if (this.debug) console.log(this.loc(\"Request invoked to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n })\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Hook per osservare i dati spediti ad un Endpoint dal Backend\r\n * \r\n * @param {EndpointDef<TIn, any>} item Endpoint su cui ascoltare\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere l'oggetto generato ad ogni chiamata dal Backend al Frontend\r\n */\r\n public observe<TIn>(item: EndpointDef<TIn, any>): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Observe request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n this.log(this.loc(\"Returning observable for required endpoint\") + \": \" + item.endpoint);\r\n return <Observable<TIn>>this.notifications$[item.endpoint];\r\n }\r\n\r\n /**\r\n * Disconnessione del sistema di SignalR\r\n * \r\n * @returns {Observable<void>} Observable a cui registrarsi che viene chiamato quando la disconnessione è terminata\r\n */\r\n public disconnect(): Observable<void> {\r\n //NO-OP se non attivo\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Disconnection request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n return from(this.connection.stop()).pipe(\r\n catchError((err, caught) => { console.log(err); return of(null); }),\r\n tap(() => {\r\n this.log(this.loc(\"Disconnection request honored\"));\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Taglia un log troppo lungo\r\n * \r\n * @param {string} text Log da tagliare\r\n * @param {number} maxchars Numero massimo di caratteri da tenere\r\n * \r\n * @returns {string} Log tagliato\r\n */\r\n private substringLog(text: string, maxchars: number = 120): string {\r\n return text.length > maxchars ? text.substr(0, maxchars) + \"[...]\" : text;\r\n }\r\n\r\n /**\r\n * Stampa un log a console\r\n * \r\n * @param {string} message Messaggio da stampare\r\n */\r\n private log(message: string) {\r\n if (this.debug)\r\n console.log(\"@signalr-notifications: \" + message)\r\n }\r\n\r\n /**\r\n * Helper di localizzazione\r\n * \r\n * @param {string} message Messaggio da tradurre\r\n * \r\n * @returns {string} Messaggio tradotto\r\n */\r\n private loc(message: string): string {\r\n if (!Loc[message]) {\r\n console.warn(\"Untranslated message: \" + message)\r\n return \"\";\r\n }\r\n return Loc[message][this.locale];\r\n }\r\n}","\r\nimport { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { SignalrNotificationsModuleConfig } from './config/SignalrNotificationsModuleConfig';\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { NotificationsService } from './signalr-notifications.service';\r\nimport { ENDPOINT_URL, SIGNALR_ENABLED, DEBUG_MODE, LOCALE, MESSAGE_PACK, AUTO_RECONNECT } from './tokens';\r\n\r\n@NgModule()\r\nexport class SignalrNotificationsModule {\r\n static forRoot(config?: SignalrNotificationsModuleConfig): ModuleWithProviders<SignalrNotificationsModule> {\r\n return {\r\n ngModule: SignalrNotificationsModule,\r\n providers: [\r\n NotificationsService,\r\n { provide: BaseMessageService, useClass: config?.messageService || BaseMessageService },\r\n { provide: ENDPOINT_URL, useValue: config?.endpointUrl },\r\n { provide: LOCALE, useValue: config?.locale || 'it-IT' },\r\n { provide: SIGNALR_ENABLED, useValue: config?.enabled != null ? config?.enabled : true },\r\n { provide: DEBUG_MODE, useValue: config?.debugMode != null ? config?.debugMode : false },\r\n { provide: MESSAGE_PACK, useValue: config?.autoReconnect != null ? config?.autoReconnect : false },\r\n { provide: AUTO_RECONNECT, useValue: config?.useMessagePack != null ? config?.useMessagePack : false },\r\n ]\r\n };\r\n }\r\n}","/**\r\n * Definisce un Endpoint che spedisce un'informazione di tipo TIn e restituisce un'informazione di tipo TOut\r\n */\r\nexport class EndpointDef<TIn, TOut> {\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @param {string} endpoint Nome del metodo da chiamare nell'Hub del Backend contattato\r\n * @param {TIn} inTypeDefault Default per il tipo TIn. Utilizzato per fare Typecheck sulle chiamate da Backend a Frontend\r\n * @param {TOut} outTypeDefault Default per il tipo TOut. Utilizzato per fare Typecheck sulle chiamate da Frontend a Backend\r\n */\r\n constructor(public endpoint: string, public inTypeDefault: TIn, public outTypeDefault: TOut) { }\r\n\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo INPUT */\r\n public static In<TIn>(name: string, inTypeDefault: TIn): EndpointDef<TIn, void> {\r\n return new EndpointDef<TIn, void>(name, inTypeDefault, undefined);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */\r\n public static Out<TOut>(name: string, outTypeDefault: TOut): EndpointDef<void, TOut> {\r\n return new EndpointDef<void, TOut>(name, undefined, outTypeDefault);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */\r\n public static Bi<TIn, TOut>(name: string, inTypeDefault: TIn, outTypeDefault: TOut): EndpointDef<TIn, TOut> {\r\n return new EndpointDef<TIn, TOut>(name, inTypeDefault, outTypeDefault);\r\n }\r\n}","// Angular\r\nimport { Type } from '@angular/core';\r\n\r\n// Modelli\r\nimport { BaseMessageService } from '../models/BaseMessageService';\r\n\r\n/**\r\n * Classe di configurazione per la libreria\r\n */\r\nexport class SignalrNotificationsModuleConfig {\r\n\r\n /**\r\n * Url nei confronti del quale aprire la connessione SignalR\r\n */\r\n endpointUrl : string;\r\n\r\n /**\r\n * Servizio che definisce i messaggi di IN e OUT coi loro default\r\n */\r\n messageService? : Type<BaseMessageService>;\r\n\r\n /**\r\n * Indica se abilitare o meno la connessione SignalR nei confronti dell'URL **hubUrl**\r\n */\r\n enabled? : boolean;\r\n\r\n /**\r\n * Indica se utilizzare message pack come protocollo di trasmissione\r\n */\r\n useMessagePack? : boolean;\r\n\r\n /**\r\n * Indica se tentare di riconnettersi automaticamente quando la connessione cade\r\n */\r\n autoReconnect? : boolean;\r\n\r\n /**\r\n * Indica se scrivere o meno i messaggi di debug\r\n */\r\n debugMode? : boolean;\r\n\r\n /**\r\n * Lingua dei feedback a console, sono supportati 'it-IT' ed 'en-US'\r\n */\r\n locale? : string\r\n}"]}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Generated bundle index. Do not edit.
|
|
3
3
|
*/
|
|
4
4
|
export * from './public-api';
|
|
5
|
-
export { AUTO_RECONNECT as ɵf, DEBUG_MODE as ɵc,
|
|
5
|
+
export { AUTO_RECONNECT as ɵf, DEBUG_MODE as ɵc, ENDPOINT_URL as ɵa, LOCALE as ɵd, MESSAGE_PACK as ɵe, SIGNALR_ENABLED as ɵb } from './lib/tokens';
|