@chat21/chat21-ionic 3.4.27-rc23 → 3.4.27-rc24

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,9 @@
8
8
  ### **Copyrigth**:
9
9
  *Tiledesk SRL*
10
10
 
11
+ # 3.4.27-rc24
12
+ - **added**: implementation of multiple message in wss onmessage
13
+
11
14
  # 3.4.27-rc23
12
15
  - **added**: keepAlive worker for MQTT connection
13
16
 
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-rc23",
4
+ "version": "3.4.27-rc24",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://tiledesk.com/",
7
7
  "repository": {
@@ -38,7 +38,7 @@ export class WebSocketJs {
38
38
  const sub = this.subscriptions.get(msg.topic);
39
39
  if (!sub) return;
40
40
 
41
- let object = { event: msg.payload, data: msg };
41
+ let object = { event: msg.payload, data: msg.data };
42
42
  switch (msg.method) {
43
43
  case 'CREATE': sub.onCreate?.(msg.payload, object); break;
44
44
  case 'UPDATE': sub.onUpdate?.(msg.payload, object); break;
@@ -151,7 +151,23 @@ function handleMessage(msg: WSMessage) {
151
151
 
152
152
  if (!topic) return;
153
153
 
154
+ // --- GESTIONE ARRAY DI MESSAGGI ---
155
+ const messages = Array.isArray(msg.payload.message) ? msg.payload.message : [msg.payload.message];
154
156
  // Notifica solo le subscription che matchano
157
+ subscriptions.forEach(sub => {
158
+ if (sub.topic === topic) {
159
+ messages.forEach(element => {
160
+ postMessage({
161
+ topic,
162
+ method,
163
+ payload: element, // singolo elemento
164
+ data: msg // payload completo per eventuali onData globali
165
+ }, undefined);
166
+ });
167
+ }
168
+ });
169
+
170
+
155
171
  subscriptions.forEach(sub => {
156
172
  if (sub.topic === topic) {
157
173
  postMessage({ topic, method, payload, msg }, undefined);