livedesk 0.1.38 → 0.1.40

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.
@@ -2657,6 +2657,19 @@ export function createRemoteHub(options = {}) {
2657
2657
  return false;
2658
2658
  }
2659
2659
 
2660
+ const commandId = safeString(message.commandId, 128);
2661
+ const activeCommandId = safeString(device.activeLiveStream.commandId, 128);
2662
+ if (commandId && activeCommandId && commandId !== activeCommandId) {
2663
+ emitRemoteEvent('RemoteLiveStreamOpenIgnored', device, {
2664
+ reason: 'stale-live-stream-generation',
2665
+ streamId,
2666
+ commandId,
2667
+ activeCommandId,
2668
+ transport
2669
+ });
2670
+ return false;
2671
+ }
2672
+
2660
2673
  const transfer = buildRemoteFrameTransferDescriptorFromMessage(message, device.activeLiveStream.mode || DEFAULT_REMOTE_FRAME_MODE);
2661
2674
  const openedAt = safeString(message.openedAt, 80) || device.lastSeenAt || new Date().toISOString();
2662
2675
  device.activeLiveStream = {
@@ -2697,6 +2710,7 @@ export function createRemoteHub(options = {}) {
2697
2710
  : safeString(framePayload, MAX_STREAM_BASE64_CHARS + 1);
2698
2711
  const frameSeq = Number(message.frameSeq);
2699
2712
  const streamId = safeString(message.streamId, 128) || 'live';
2713
+ const commandId = safeString(message.commandId, 128);
2700
2714
  if (!device.activeLiveStream?.active || device.activeLiveStream.streamId !== streamId) {
2701
2715
  device.counters.liveFramesDropped += 1;
2702
2716
  emitRemoteEvent('RemoteFrameDropped', device, {
@@ -2707,6 +2721,19 @@ export function createRemoteHub(options = {}) {
2707
2721
  });
2708
2722
  return false;
2709
2723
  }
2724
+ const activeCommandId = safeString(device.activeLiveStream.commandId, 128);
2725
+ if (commandId && activeCommandId && commandId !== activeCommandId) {
2726
+ device.counters.liveFramesDropped += 1;
2727
+ emitRemoteEvent('RemoteFrameDropped', device, {
2728
+ reason: 'stale-live-stream-generation-frame',
2729
+ streamId,
2730
+ commandId,
2731
+ activeCommandId,
2732
+ frameSeq: Number.isFinite(frameSeq) ? frameSeq : null,
2733
+ transport
2734
+ });
2735
+ return false;
2736
+ }
2710
2737
 
2711
2738
  const byteLength = normalizeFrameByteLength(framePayload, frameData);
2712
2739
  if ((!Buffer.isBuffer(framePayload) && !frameData)
@@ -2745,7 +2772,7 @@ export function createRemoteHub(options = {}) {
2745
2772
  device.latestLiveFrame = {
2746
2773
  streamId,
2747
2774
  frameSeq,
2748
- commandId: safeString(message.commandId, 128),
2775
+ commandId,
2749
2776
  width: Number.isFinite(Number(message.width)) ? Number(message.width) : 0,
2750
2777
  height: Number.isFinite(Number(message.height)) ? Number(message.height) : 0,
2751
2778
  mimeType,
package/hub/src/server.js CHANGED
@@ -244,6 +244,7 @@ function buildRemoteFrameBinaryPacket(frameEvent) {
244
244
  deviceId: frameEvent.deviceId || frame.deviceId || '',
245
245
  frameSeq: Number(frame.frameSeq || 0) || 0,
246
246
  streamId: frame.streamId || '',
247
+ commandId: frame.commandId || '',
247
248
  width: Number(frame.width || 0) || 0,
248
249
  height: Number(frame.height || 0) || 0,
249
250
  mimeType: frameEvent.mimeType || frame.mimeType || frame.format || 'image/jpeg',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livedesk",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "LiveDesk Hub and client launcher",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "node": ">=20"
31
31
  },
32
32
  "dependencies": {
33
- "@livedesk/client": "0.1.36",
33
+ "@livedesk/client": "0.1.37",
34
34
  "cors": "^2.8.5",
35
35
  "express": "^4.21.2",
36
36
  "ws": "^8.18.3"