@chat21/chat21-ionic 3.4.27-rc20 → 3.4.27-rc21

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/CHANGELOG.md CHANGED
@@ -8,6 +8,10 @@
8
8
  ### **Copyrigth**:
9
9
  *Tiledesk SRL*
10
10
 
11
+ # 3.4.27-rc21
12
+ - **changed**: new wss reconnect and timeout keepalive
13
+ - **bug-fixed**: cannot route if senderFullaname contains /
14
+
11
15
  # 3.4.27-rc20
12
16
  - **added**: onOpenTicketExternally event in triggerEvents service
13
17
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
3
  "author": "Tiledesk SRL",
4
- "version": "3.4.27-rc20",
4
+ "version": "3.4.27-rc21",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://tiledesk.com/",
7
7
  "repository": {
@@ -896,7 +896,7 @@ export class AppComponent implements OnInit {
896
896
 
897
897
  let pageUrl = 'conversation-detail/'
898
898
  if (IDConv && FullNameConv) {
899
- pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
899
+ pageUrl += IDConv + '/' + encodeURIComponent(FullNameConv) + '/' + Convtype
900
900
  }
901
901
 
902
902
  const queryParams = this.route.snapshot.queryParams;
@@ -904,7 +904,7 @@ export class AppComponent implements OnInit {
904
904
  pageUrl += queryString ? `?${queryString}` : '';
905
905
 
906
906
  // replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
907
- this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ));
907
+ this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'));
908
908
 
909
909
 
910
910
  // const DASHBOARD_URL = this.appConfigProvider.getConfig().DASHBOARD_URL;
@@ -1356,7 +1356,7 @@ export class AppComponent implements OnInit {
1356
1356
  subscribeChangedConversationSelected = (user: UserModel, type: string) => {
1357
1357
  this.logger.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
1358
1358
  // this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
1359
- this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
1359
+ this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + encodeURIComponent(user.fullname) + '/' + type);
1360
1360
  }
1361
1361
 
1362
1362
  subscribeProfileInfoButtonLogOut = (hasClickedLogout) => {
@@ -1532,10 +1532,10 @@ export class AppComponent implements OnInit {
1532
1532
  let Convtype = 'active'
1533
1533
 
1534
1534
  if (IDConv && FullNameConv) {
1535
- pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
1535
+ pageUrl += IDConv + '/' + encodeURIComponent(FullNameConv) + '/' + Convtype
1536
1536
  }
1537
1537
  // replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
1538
- this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ));
1538
+ this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'));
1539
1539
  } else {
1540
1540
  console.log("FCM: Received in foreground", JSON.stringify(data));
1541
1541
  // let IDConv = data.recipient
@@ -1546,7 +1546,7 @@ export class AppComponent implements OnInit {
1546
1546
  // pageUrl += IDConv + '/' + FullNameConv + '/' + Convtype
1547
1547
  // }
1548
1548
  // // replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
1549
- // this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ));
1549
+ // this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'));
1550
1550
  };
1551
1551
  });
1552
1552
  }
@@ -70,8 +70,8 @@ export class InfoContentComponent implements OnInit {
70
70
  this.route.paramMap.subscribe(params => {
71
71
  this.logger.log('[INFO-CONTENT-COMP] initialize params: ', params);
72
72
  this.conversationWith = params.get('IDConv');
73
- this.conversationWithFullname = params.get('FullNameConv');
74
- this.conv_type = params.get('Convtype');
73
+ this.conversationWithFullname = decodeURIComponent(params.get('FullNameConv'));
74
+ this.conv_type = decodeURIComponent(params.get('Convtype'));
75
75
 
76
76
  const conversationWith_segments = this.conversationWith.split('-');
77
77
 
@@ -262,8 +262,8 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
262
262
  this.route.paramMap.subscribe((params) => {
263
263
  this.logger.log('[CONVS-DETAIL] - constructor -> params: ', params)
264
264
  this.conversationWith = params.get('IDConv')
265
- this.conversationWithFullname = params.get('FullNameConv')
266
- this.conv_type = params.get('Convtype')
265
+ this.conversationWithFullname = decodeURIComponent(params.get('FullNameConv'))
266
+ this.conv_type = decodeURIComponent(params.get('Convtype'))
267
267
 
268
268
  this.events.publish('supportconvid:haschanged', this.conversationWith)
269
269
  })
@@ -925,24 +925,22 @@ export class ConversationListPage implements OnInit {
925
925
  this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile())
926
926
  this.logger.log('[CONVS-LIST-PAGE] DESKTOP (window < 768)', this.navService)
927
927
  this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected conversation_with_fullname ', this.conversationSelected)
928
- let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType
929
- pageUrl += queryString ? `?${queryString}` : '';
928
+ let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + encodeURIComponent(this.conversationSelected.conversation_with_fullname) + '/' + converationType
930
929
  this.logger.log('[CONVS-LIST-PAGE] pageURL', pageUrl)
931
930
  // replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
932
- this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ), {replaceUrl: true})
931
+ this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'), {replaceUrl: true})
933
932
  } else {
934
933
  this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected conversation_with_fullname ', this.conversationSelected)
935
934
  this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile())
936
935
  this.logger.log('[CONVS-LIST-PAGE] MOBILE (window >= 768) ', this.navService)
937
936
  let pageUrl = 'conversation-detail/' + this.uidConvSelected
938
937
  if (this.conversationSelected && this.conversationSelected.conversation_with_fullname) {
939
- pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType
938
+ pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + encodeURIComponent(this.conversationSelected.conversation_with_fullname) + '/' + converationType
940
939
  }
941
940
  pageUrl += queryString ? `?${queryString}` : '';
942
941
  this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected navigateByUrl--->: ', pageUrl)
943
942
  // replace(/\(/g, '%28').replace(/\)/g, '%29') -> used for the encoder of any round brackets
944
-
945
- this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29').replace( /#/g, "%23" ), {replaceUrl: true})
943
+ this.router.navigateByUrl(pageUrl.replace(/\(/g, '%28').replace(/\)/g, '%29'), {replaceUrl: true})
946
944
  }
947
945
  }
948
946
 
@@ -4,7 +4,6 @@ import { Router, NavigationExtras } from '@angular/router';
4
4
 
5
5
  // utils
6
6
  import { checkPlatformIsMobile } from '../../chat21-core/utils/utils';
7
- // import { ConversationDetailPage } from '../pages/conversation-detail/conversation-detail.page';
8
7
 
9
8
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
10
9
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
@@ -8,14 +8,13 @@ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
8
8
  export class WebSocketJs {
9
9
 
10
10
  public url;
11
- public onCreate;
12
- public onUpdate;
13
- public onOpen;
14
- public onData;
11
+ public onCreate?: Function;
12
+ public onUpdate?: Function;
13
+ public onOpen?: Function;
14
+ public onData?: Function;
15
15
  public ws;
16
16
  public topics;
17
17
  public callbacks;
18
- public readyState: number;
19
18
  // public userHasClosed: boolean;
20
19
 
21
20
  // HEARTBEAT https://github.com/zimv/websocket-heartbeat-js/blob/master/lib/index.js
@@ -23,13 +22,15 @@ export class WebSocketJs {
23
22
  private pongTimeoutId;
24
23
 
25
24
  public pingMsg = { action: "heartbeat", payload: { message: { text: "ping" } } }
26
-
27
25
  public pongMsg = { action: "heartbeat", payload: { message: { text: "pong" } } }
28
26
 
29
-
30
27
  public pongTimeout = 10000;
31
28
  public pingTimeout = 15000;
32
29
 
30
+ private reconnectAttempts = 0;
31
+ private readonly maxReconnectDelay = 30000;
32
+ private manuallyClosed = false;
33
+
33
34
  // nktest
34
35
  // startTimeMS = 0;
35
36
 
@@ -78,7 +79,7 @@ export class WebSocketJs {
78
79
  this.callbacks.set(topic, { onCreate: onCreate, onUpdate: onUpdate, onData: onData });
79
80
  this.logger.log('[WEBSOCKET-JS] - CALLBACK-SET - callbacks', this.callbacks);
80
81
 
81
- if (this.ws && this.ws.readyState == 1) {
82
+ if (this.ws && this.ws.readyState == WebSocket.OPEN) {
82
83
  this.logger.log('[WEBSOCKET-JS] - REF - READY STATE ', this.ws.readyState);
83
84
  this.logger.log('[WEBSOCKET-JS] - REF - READY STATE = 1 > SUBSCRIBE TO TOPICS ');
84
85
 
@@ -126,10 +127,8 @@ export class WebSocketJs {
126
127
  method: undefined
127
128
  },
128
129
  };
129
- var str = JSON.stringify(message);
130
- this.logger.log("[WEBSOCKET-JS] - SUBSCRIBE TO TOPIC - STRING TO SEND " + str, " FOR SUBSCRIBE TO TOPIC: ", topic);
131
-
132
- this.send(str, `SUBSCRIBE to ${topic}`);
130
+ this.logger.log("[WEBSOCKET-JS] - SUBSCRIBE TO TOPIC - DATA TO SEND ", message, " FOR SUBSCRIBE TO TOPIC: ", topic);
131
+ this.send(message, `SUBSCRIBE to ${topic}`);
133
132
  }
134
133
 
135
134
  // -----------------------------------------------------------------------------------------------------
@@ -170,12 +169,11 @@ export class WebSocketJs {
170
169
  method: undefined
171
170
  },
172
171
  };
173
- var str = JSON.stringify(message);
174
- this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE str " + str);
172
+ this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE " + message);
175
173
 
176
- if (this.ws && this.ws.readyState == 1) {
177
- this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE TO TOPIC - STRING TO SEND " + str, " FOR UNSUBSCRIBE TO TOPIC: ", topic);
178
- this.send(str, `UNSUSCRIBE from ${topic}`);
174
+ if (this.ws && this.ws.readyState == WebSocket.OPEN) {
175
+ this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE TO TOPIC - DATA TO SEND ", message, " FOR UNSUBSCRIBE TO TOPIC: ", topic);
176
+ this.send(message, `UNSUSCRIBE from ${topic}`);
179
177
 
180
178
  } else if (this.ws) {
181
179
  this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE TRY 'SEND' BUT READY STASTE IS : ", this.ws.readyState);
@@ -185,10 +183,10 @@ export class WebSocketJs {
185
183
  // -----------------------------------------------------------------------------------------------------
186
184
  // @ send -
187
185
  // -----------------------------------------------------------------------------------------------------
188
- send(initialMessage, calling_method) {
186
+ send(data, calling_method) {
189
187
  // this.logger.log("[WEBSOCKET-JS] - SEND - INIZIAL-MSG ", initialMessage, " CALLED BY ", calling_method);
190
188
 
191
- this.ws.send(initialMessage);
189
+ this.ws.send(JSON.stringify(data));
192
190
  }
193
191
 
194
192
 
@@ -205,6 +203,23 @@ export class WebSocketJs {
205
203
  this.ws.close();
206
204
  }
207
205
  this.heartReset();
206
+ this.manuallyClosed = true;
207
+ }
208
+
209
+ reconnect(url, onCreate, onUpdate, onData, onOpen = undefined, onOpenCallback = undefined, _topics = [], _callbacks = new Map()) {
210
+ this.reconnectAttempts++;
211
+ const delay = Math.min(this.reconnectAttempts * 1000, this.maxReconnectDelay);
212
+
213
+ console.log(`WebSocket reconnect in ${delay}ms`);
214
+ const that = this;
215
+ setTimeout(() => {
216
+ if (!that.manuallyClosed) {
217
+ that.init(url, onCreate, onUpdate, onData, onOpen, function () {
218
+ that.logger.log('[WEBSOCKET-JS] websocket IS CLOSED ... CALLING RESUSCRIBE ');
219
+ that.resubscribe();
220
+ }, that.topics, that.callbacks);
221
+ }
222
+ }, delay);
208
223
  }
209
224
 
210
225
  // -----------------------------------------------------------------------------------------------------
@@ -272,41 +287,45 @@ export class WebSocketJs {
272
287
  // -----------------------------------------------------------------------------------------------------
273
288
  // @ HeartStart
274
289
  // -----------------------------------------------------------------------------------------------------
275
- heartStart() {
290
+ private heartStart() {
276
291
  // this.getRemainingTime();
277
- this.pingTimeoutId = setTimeout(() => {
278
-
279
- // Qui viene inviato un battito cardiaco Dopo averlo ricevuto, viene restituito un messaggio di battito cardiaco.
280
- // onmessage Ottieni il battito cardiaco restituito per indicare che la connessione è normale
281
- if (this.ws && this.ws.readyState == 1) {
282
-
283
- this.logger.log("[WEBSOCKET-JS] - HEART-START - SEND PING-MSG");
284
-
285
- this.send(JSON.stringify(this.pingMsg), 'HEART-START')
286
292
 
287
- } else if (this.ws) {
293
+ // usa intervallo adattivo se tab è in background (Chrome throtla i timer)
294
+ const adaptivePing = document.hidden ? this.pingTimeout * 3 : this.pingTimeout;
288
295
 
289
- this.logger.log("[WEBSOCKET-JS] - HEART-START - TRY TO SEND PING-MSG BUT READY STATE IS ", this.ws.readyState);
296
+ // pianifica invio ping
297
+ this.pingTimeoutId = setTimeout(() => {
298
+ if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
290
299
 
291
- }
300
+ // Qui viene inviato un battito cardiaco. Dopo averlo ricevuto, viene restituito un messaggio di battito cardiaco.
301
+ // onmessage Ottieni il battito cardiaco restituito per indicare che la connessione è normale
302
+ this.send(this.pingMsg, 'HEART-START')
292
303
 
293
304
  // Se non viene ripristinato dopo un determinato periodo di tempo, il backend viene attivamente disconnesso
294
305
  this.pongTimeoutId = setTimeout(() => {
295
- this.logger.log("[WEBSOCKET-JS] - HEART-START - PONG-TIMEOUT-ID - CLOSE WS ");
306
+ this.logger.log("[WEBSOCKET-JS] - HEART-START - PONG-TIMEOUT-ID - CLOSE WS ");
296
307
  // se onclose Si esibirà reconnect,Eseguiamo ws.close() Bene, se lo esegui direttamente reconnect Si innescherà onclose Causa riconnessione due volte
297
308
  this.ws.close();
298
- }, this.pongTimeout);
309
+ }, this.pongTimeout) as unknown as number;
310
+
311
+
312
+ }, adaptivePing);
299
313
 
300
- }, this.pingTimeout);
301
314
  }
302
315
 
303
316
  // -----------------------------------------------------------------------------------------------------
304
317
  // @ heartReset
305
318
  // -----------------------------------------------------------------------------------------------------
306
- heartReset() {
307
- // this.logger.log("[WEBSOCKET-JS] - HEART-RESET");
308
- clearTimeout(this.pingTimeoutId);
309
- clearTimeout(this.pongTimeoutId);
319
+ private heartReset() {
320
+ if (this.pongTimeoutId !== undefined) {
321
+ clearTimeout(this.pongTimeoutId);
322
+ this.pongTimeoutId = undefined;
323
+ }
324
+
325
+ if (this.pingTimeoutId !== undefined) {
326
+ clearTimeout(this.pingTimeoutId);
327
+ this.pingTimeoutId = undefined;
328
+ }
310
329
  }
311
330
 
312
331
  // -----------------------------------------------------------------------------------------------------
@@ -315,7 +334,7 @@ export class WebSocketJs {
315
334
  init(url, onCreate, onUpdate, onData, onOpen = undefined, onOpenCallback = undefined, _topics = [], _callbacks = new Map()) {
316
335
 
317
336
 
318
-
337
+ this.manuallyClosed = false;
319
338
  this.url = url;
320
339
  this.onCreate = onCreate;
321
340
  this.onUpdate = onUpdate;
@@ -360,19 +379,12 @@ export class WebSocketJs {
360
379
  that.ws.onopen = function (e) {
361
380
  that.logger.log('[WEBSOCKET-JS] - websocket is connected ...', e);
362
381
 
363
- // -----------------
364
- // @ heartCheck
365
- // -----------------
382
+ // Inizializza heartbeat
366
383
  that.heartCheck();
384
+ that.reconnectAttempts = 0;
367
385
 
368
-
369
- if (onOpenCallback) {
370
- onOpenCallback();
371
- }
372
-
373
- if (that.onOpen) {
374
- that.onOpen();
375
- }
386
+ if (onOpenCallback) { onOpenCallback(); }
387
+ if (that.onOpen) { that.onOpen(); }
376
388
 
377
389
  }
378
390
 
@@ -389,13 +401,21 @@ export class WebSocketJs {
389
401
  // --------------------
390
402
  // @ init > resubscribe
391
403
  // --------------------
404
+ that.heartReset();
392
405
 
393
- setTimeout(function () {
394
- that.init(url, onCreate, onUpdate, onData, onOpen, function () {
406
+ if (!that.manuallyClosed) {
407
+ that.reconnect(url, onCreate, onUpdate, onData, onOpen, function () {
395
408
  that.logger.log('[WEBSOCKET-JS] websocket IS CLOSED ... CALLING RESUSCRIBE ');
396
409
  that.resubscribe();
397
410
  }, that.topics, that.callbacks);
398
- }, 3000);
411
+ }
412
+
413
+ // setTimeout(function () {
414
+ // that.init(url, onCreate, onUpdate, onData, onOpen, function () {
415
+ // that.logger.log('[WEBSOCKET-JS] websocket IS CLOSED ... CALLING RESUSCRIBE ');
416
+ // that.resubscribe();
417
+ // }, that.topics, that.callbacks);
418
+ // }, 3000);
399
419
  }
400
420
 
401
421
  // -----------------------------------------------------------------------------------------------------
@@ -415,8 +435,9 @@ export class WebSocketJs {
415
435
  // let test = '{ "action": "publish","payload": {"topic": "/5df26badde7e1c001743b63c/requests", "method": "CREATE", "message": [ { "_id": "5f29372d690e6f0034edf100", "status": 200, "preflight": false, "hasBot": true, "participants": ["bot_5df272e8de7e1c001743b645"], "participantsAgents": [], "participantsBots": ["5df272e8de7e1c001743b645"], "request_id": "support-group-MDszsSJlwqQn1_WCh6u", "requester": "5f29371b690e6f0034edf0f5", "lead": "5f29372d690e6f0034edf0ff", "first_text": "ocourse the email is valid ","department": "5df26badde7e1c001743b63e", "agents": [{"user_available": true,"online_status": "online", "number_assigned_requests": 35, "_id": "5e0f2119705a35001725714d","id_project": "5df26badde7e1c001743b63c", "id_user": "5aaa99024c3b110014b478f0", "role": "admin", "createdBy": "5df26ba1de7e1c001743b637","createdAt": "2020-01-03T11:10:17.123Z", "updatedAt": "2020-01-03T11:10:17.123Z", "__v": 0 }, { "user_available": false, "online_status": "offline", "number_assigned_requests": 0, "_id": "5e1a13824437eb0017f712b4", "id_project": "5df26badde7e1c001743b63c","id_user": "5ac7521787f6b50014e0b592", "role": "admin", "createdBy": "5df26ba1de7e1c001743b637", "createdAt": "2020-01-11T18:27:14.657Z","updatedAt": "2020-01-11T18:27:14.657Z", "__v": 0}, { "user_available": false,"online_status": "offline", "number_assigned_requests": 0, "_id": "5df26bdfde7e1c001743b640", "id_project": "5df26badde7e1c001743b63c", "id_user": "5de9200d6722370017731969","role": "admin","createdBy": "5df26ba1de7e1c001743b637", "createdAt": "2019-12-12T16:33:35.244Z", "updatedAt": "2019-12-12T16:33:35.244Z","__v": 0 }, {"user_available": true, "online_status": "online","number_assigned_requests": -11, "_id": "5eb1a3647ac005003480f54d", "id_project": "5df26badde7e1c001743b63c","id_user": "5e09d16d4d36110017506d7f","role": "owner", "createdBy": "5aaa99024c3b110014b478f0","createdAt": "2020-05-05T17:33:24.328Z", "updatedAt": "2020-05-05T17:33:24.328Z","__v": 0}], "sourcePage": "https://www.tiledesk.com/pricing-self-managed/", "language": "en","userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36","attributes": { "departmentId": "5df26badde7e1c001743b63e","departmentName": "Default Department","ipAddress": "115.96.30.154","client": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36","sourcePage": "https://www.tiledesk.com/pricing-self-managed/", "projectId": "5df26badde7e1c001743b63c", "requester_id": "ce31d3fd-a358-49c7-9b9f-5aead8330063", "subtype": "info","decoded_jwt": {"_id": "ce31d3fd-a358-49c7-9b9f-5aead8330063","firstname": "Guest", "id": "ce31d3fd-a358-49c7-9b9f-5aead8330063", "fullName": "Guest ","iat": 1596536604,"aud": "https://tiledesk.com","iss": "https://tiledesk.com","sub": "guest","jti": "702a4a7e-e56a-43cf-aadd-376f7c12f633"}},"id_project": "5df26badde7e1c001743b63c","createdBy": "ce31d3fd-a358-49c7-9b9f-5aead8330063","tags": [], "notes": [],"channel": {"name": "chat21"},"createdAt": "2020-08-04T10:23:41.641Z","updatedAt": "2021-03-25T18:01:13.371Z","__v": 3,"assigned_at": "2020-08-04T10:25:26.059Z","channelOutbound": {"name": "chat21"},"snapshot": {"agents": [{"id_user": "5aaa99024c3b110014b478f0"}, {"id_user": "5ac7521787f6b50014e0b592"}, {"id_user": "5de9200d6722370017731969"}, { "id_user": "5e09d16d4d36110017506d7f"}]},"id": "5f29372d690e6f0034edf100","requester_id": "5f29372d690e6f0034edf0ff"}]}}'
416
436
  // let test_due = '{ "action": "publish","payload": {"topic": "/5df26badde7e1c001743b63c/requests", "method": "CREATE", "message": [ { "_id": "5f29372d690e6f0034edf100", "status": 200, "preflight": false, "hasBot": true, "participants": ["bot_5df272e8de7e1c001743b645"], "participantsAgents": [], "participantsBots": ["5df272e8de7e1c001743b645"], "request_id": "support-group-MDszsSJlwqQn1_WCh6u", "requester": "5f29371b690e6f0034edf0f5", "lead": "5f29372d690e6f0034edf0ff", "first_text": "ocourse the email is valid ","department": "5df26badde7e1c001743b63e", "agents": [{"user_available": true,"online_status": "online", "number_assigned_requests": 35, "_id": "5e0f2119705a35001725714d","id_project": "5df26badde7e1c001743b63c", "id_user": "5aaa99024c3b110014b478f0", "role": "admin", "createdBy": "5df26ba1de7e1c001743b637","createdAt": "2020-01-03T11:10:17.123Z", "updatedAt": "2020-01-03T11:10:17.123Z", "__v": 0 }, { "user_available": false, "online_status": "offline", "number_assigned_requests": 0, "_id": "5e1a13824437eb0017f712b4", "id_project": "5df26badde7e1c001743b63c","id_user": "5ac7521787f6b50014e0b592", "role": "admin", "createdBy": "5df26ba1de7e1c001743b637", "createdAt": "2020-01-11T18:27:14.657Z","updatedAt": "2020-01-11T18:27:14.657Z", "__v": 0}, { "user_available": false,"online_status": "offline", "number_assigned_requests": 0, "_id": "5df26bdfde7e1c001743b640", "id_project": "5df26badde7e1c001743b63c", "id_user": "5de9200d6722370017731969","role": "admin","createdBy": "5df26ba1de7e1c001743b637", "createdAt": "2019-12-12T16:33:35.244Z", "updatedAt": "2019-12-12T16:33:35.244Z","__v": 0 }, {"user_available": true, "online_status": "online","number_assigned_requests": -11, "_id": "5eb1a3647ac005003480f54d", "id_project": "5df26badde7e1c001743b63c","id_user": "5e09d16d4d36110017506d7f","role": "owner", "createdBy": "5aaa99024c3b110014b478f0","createdAt": "2020-05-05T17:33:24.328Z", "updatedAt": "2020-05-05T17:33:24.328Z","__v": 0}], "sourcePage": "https://www.tiledesk.com/pricing-self-managed/", "language": "en","userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36","attributes": { "departmentId": "5df26badde7e1c001743b63e","departmentName": "Default Department","ipAddress": "115.96.30.154","client": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36","sourcePage": "https://www.tiledesk.com/pricing-self-managed/", "projectId": "5df26badde7e1c001743b63c", "requester_id": "ce31d3fd-a358-49c7-9b9f-5aead8330063", "subtype": "info","decoded_jwt": {"_id": "ce31d3fd-a358-49c7-9b9f-5aead8330063","firstname": "Guest", "id": "ce31d3fd-a358-49c7-9b9f-5aead8330063", "fullName": "Guest ","iat": 1596536604,"aud": "https://tiledesk.com","iss": "https://tiledesk.com","sub": "guest","jti": "702a4a7e-e56a-43cf-aadd-376f7c12f633"}},"id_project": "5df26badde7e1c001743b63c","createdBy": "ce31d3fd-a358-49c7-9b9f-5aead8330063","tags": [], "notes": [],"channel": {"name": "chat21"},"createdAt": "2020-08-04T10:23:41.641Z","updatedAt": "2021-03-25T18:01:13.371Z","__v": 3,"assigned_at": "2020-08-04T10:25:26.059Z","channelOutbound": {"name": "chat21"},"_snapshot": {"agents": [{"id_user": "5aaa99024c3b110014b478f0"}, {"id_user": "5ac7521787f6b50014e0b592"}, {"id_user": "5de9200d6722370017731969"}, { "id_user": "5e09d16d4d36110017506d7f"}]},"id": "5f29372d690e6f0034edf100","requester_id": "5f29372d690e6f0034edf0ff"}]}}'
417
437
 
438
+ let json;
418
439
  try {
419
- var json = JSON.parse(message.data);
440
+ json = JSON.parse(message.data);
420
441
  // var json = JSON.parse(test_due);
421
442
  // this.logger.log('% »»» WebSocketJs - websocket onmessage JSON.parse(message.data) json payload', json.payload);
422
443
  // this.logger.log('% »»» WebSocketJs - websocket onmessage JSON.parse(message.data) json payload topic', json.payload.topic);
@@ -426,30 +447,27 @@ export class WebSocketJs {
426
447
  return;
427
448
  }
428
449
 
450
+
451
+ // -----------------------
452
+ // HEARTBEAT HANDLING
453
+ // @ check the action and the message's text -
454
+ // if action is 'heartbeat' and text is ping send the PONG message and return
455
+ // -----------------------
456
+ if (json.action === "heartbeat") {
457
+ const text = json?.payload?.message?.text;
458
+
459
+ // Server -> Client ping
460
+ if (text === "ping") {
461
+ that.send(that.pongMsg, 'ON-MESSAGE');
462
+ return;
463
+ }
429
464
 
430
- // -------------------
431
- // @ heartCheck
432
- // -------------------
433
- that.heartCheck();
434
-
435
- // --------------------------------------------------------------------------------------------------------------------
436
- // @ check the action and the message's text - if action is 'heartbeat' and text is ping send the PONG message and return
437
- // --------------------------------------------------------------------------------------------------------------------
438
-
439
- if (json.action == "heartbeat") {
440
-
441
- if (json.payload.message.text == "ping") {
442
- // -------------------
443
- // @ send PONG
444
- // -------------------
445
- // that.logger.log('[WEBSOCKET-JS] - RECEIVED PING -> SEND PONG MSG');
446
-
447
- that.send(JSON.stringify(that.pongMsg), 'ON-MESSAGE')
448
-
449
- } else {
450
- // nk
451
- // this.logger.log('[WEBSOCKET-JS] - NOT RECEIVED PING ');
465
+ // Server -> Client pong (risposta al nostro ping)
466
+ if (text === "pong") {
467
+ that.heartCheck();
468
+ return;
452
469
  }
470
+
453
471
  return;
454
472
  }
455
473
 
@@ -26,8 +26,6 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
26
26
  import { createTranslateLoader } from 'src/chat21-core/utils/utils';
27
27
  import { HttpClient } from '@angular/common/http';
28
28
 
29
- // import { MessageTextAreaComponent } from '../components/conversation-detail/message-text-area/message-text-area.component'; // MessageTextAreaComponent is part of the declarations ConversationDetailPageModule
30
-
31
29
  @NgModule({
32
30
  declarations: [
33
31
  //CONVERSATION_LIST