versacall-core-library-react 2.0.84-dev → 2.0.85-dev

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.
@@ -216,8 +216,8 @@ function onConnack(body) {
216
216
  // Resubscribe every channel the app has asked for.
217
217
  // This handles both initial subscription after connect AND
218
218
  // re-subscription after an unintended disconnect / reconnect.
219
- activeSubscriptions.forEach((_, topic) => {
220
- wsSend(buildSubscribe(nextPacketId(), topic));
219
+ activeSubscriptions.forEach(sub => {
220
+ wsSend(buildSubscribe(nextPacketId(), "".concat(sub.channelKey, "/").concat(sub.channelName, "/")));
221
221
  });
222
222
  }
223
223
 
@@ -259,7 +259,7 @@ function onPublish(flags, body) {
259
259
  // Look up channelName from activeSubscriptions — emitter-io only
260
260
  // exposes the channelName (not the full key/name/ MQTT topic)
261
261
  const sub = activeSubscriptions.get(topic);
262
- const channelName = sub ? sub.channelName : topic.replace(/\/$/, '').split('/').slice(1).join('/');
262
+ const channelName = sub ? sub.channelName : topic.replace(/\/$/, '');
263
263
  broadcast({
264
264
  type: 'MESSAGE',
265
265
  channel: channelName,
@@ -391,25 +391,24 @@ function handlePortMessage(port, msg) {
391
391
  }
392
392
  case 'SUBSCRIBE':
393
393
  {
394
- // topic format matches emitter-io: "{channelKey}/{channelName}/"
395
- const topic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
396
- activeSubscriptions.set(topic, {
394
+ const mqttTopic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
395
+ const lookupKey = "".concat(msg.channelName, "/");
396
+ activeSubscriptions.set(lookupKey, {
397
397
  channelKey: msg.channelKey,
398
398
  channelName: msg.channelName
399
399
  });
400
- // Send SUBSCRIBE immediately if already connected; otherwise the topic
401
- // will be replayed in onConnack() when the connection comes up.
402
400
  if (mqttConnected) {
403
- wsSend(buildSubscribe(nextPacketId(), topic));
401
+ wsSend(buildSubscribe(nextPacketId(), mqttTopic));
404
402
  }
405
403
  break;
406
404
  }
407
405
  case 'UNSUBSCRIBE':
408
406
  {
409
- const topic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
410
- activeSubscriptions.delete(topic);
407
+ const lookupKey = "".concat(msg.channelName, "/");
408
+ activeSubscriptions.delete(lookupKey);
409
+ const mqttTopic = "".concat(msg.channelKey, "/").concat(msg.channelName, "/");
411
410
  if (mqttConnected) {
412
- wsSend(buildUnsubscribe(nextPacketId(), topic));
411
+ wsSend(buildUnsubscribe(nextPacketId(), mqttTopic));
413
412
  }
414
413
  break;
415
414
  }
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "versacall": {
3
3
  "title": "Versacall Core Library React",
4
4
  "applicationType": "react-library",
5
- "build": 84
5
+ "build": 85
6
6
  },
7
7
  "name": "versacall-core-library-react",
8
- "version": "2.0.84-dev",
8
+ "version": "2.0.85-dev",
9
9
  "description": "Versacall Core Library",
10
10
  "main": "dist/index.js",
11
11
  "module": "dist/index.js",