livedesk 0.1.142 → 0.1.144

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.
@@ -124,7 +124,7 @@ const DEFAULT_PUBLIC_IP_TIMEOUT_MS = 1800;
124
124
  const DUPLICATE_DEVICE_ACTIVE_REJECT_MS = 15000;
125
125
  const DUPLICATE_DEVICE_LOG_THROTTLE_MS = 60000;
126
126
  const DUPLICATE_DEVICE_RETRY_AFTER_MS = 30000;
127
- const AGENT_BINARY_INGRESS_QUEUE_PACKETS = 64;
127
+ const AGENT_BINARY_INGRESS_QUEUE_PACKETS = 256;
128
128
  const AGENT_BINARY_INGRESS_DRAIN_BUDGET_PACKETS = 64;
129
129
  const SYNTHETIC_FRAME_DATA_URL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAYAAAD0In+KAAAADElEQVR42mP8z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC';
130
130
  const SYNTHETIC_FRAME_PAYLOAD = Buffer.from(SYNTHETIC_FRAME_DATA_URL.split(',')[1], 'base64');
@@ -1348,9 +1348,7 @@ export function createRemoteHub(options = {}) {
1348
1348
  const audioSockets = new Map();
1349
1349
  const fileSockets = new Map();
1350
1350
  const allSockets = new Set();
1351
- const agentBinaryIngressLanes = [];
1352
1351
  const duplicateDeviceLogAt = new Map();
1353
- let agentBinaryIngressDraining = false;
1354
1352
  let server = null;
1355
1353
  let started = false;
1356
1354
  let boundPort = requestedPort;
@@ -3314,16 +3312,6 @@ export function createRemoteHub(options = {}) {
3314
3312
  device.activeLiveStream.monitorIndex = device.latestLiveFrame.monitorIndex;
3315
3313
  device.activeLiveStream.monitorCount = device.latestLiveFrame.monitorCount;
3316
3314
  device.counters.liveFramesReceived += 1;
3317
- emitRemoteEvent('RemoteFrameReceived', device, {
3318
- streamId,
3319
- frameSeq,
3320
- width: device.latestLiveFrame.width,
3321
- height: device.latestLiveFrame.height,
3322
- mode: device.latestLiveFrame.mode,
3323
- transport,
3324
- contentHash,
3325
- sameContentStreak
3326
- });
3327
3315
  return true;
3328
3316
  }
3329
3317
 
@@ -3391,13 +3379,6 @@ export function createRemoteHub(options = {}) {
3391
3379
  mimeType,
3392
3380
  byteLength
3393
3381
  });
3394
- emitRemoteEvent('RemoteAudioFrameReceived', device, {
3395
- streamId,
3396
- frameSeq,
3397
- mimeType,
3398
- byteLength,
3399
- transport
3400
- });
3401
3382
  return true;
3402
3383
  }
3403
3384
 
@@ -3472,52 +3453,36 @@ export function createRemoteHub(options = {}) {
3472
3453
  }
3473
3454
 
3474
3455
  state.binaryQueueSocket = socket;
3475
- if (state.binaryQueueScheduled !== true) {
3476
- state.binaryQueueScheduled = true;
3477
- agentBinaryIngressLanes.push(state);
3456
+ if (state.binaryQueueScheduled === true) {
3457
+ return;
3478
3458
  }
3479
- drainAgentBinaryIngressRoundRobin();
3459
+ state.binaryQueueScheduled = true;
3460
+ setImmediate(() => drainAgentBinaryIngressLane(state));
3480
3461
  }
3481
3462
 
3482
- function drainAgentBinaryIngressRoundRobin() {
3483
- if (agentBinaryIngressDraining) {
3463
+ function drainAgentBinaryIngressLane(state) {
3464
+ state.binaryQueueScheduled = false;
3465
+ const socket = state.binaryQueueSocket;
3466
+ if (state.closed || !socket || socket.destroyed) {
3467
+ if (Array.isArray(state.binaryQueue)) {
3468
+ state.binaryQueue.length = 0;
3469
+ }
3484
3470
  return;
3485
3471
  }
3486
- agentBinaryIngressDraining = true;
3487
- setImmediate(() => {
3488
- agentBinaryIngressDraining = false;
3489
- let processed = 0;
3490
- while (agentBinaryIngressLanes.length > 0 && processed < AGENT_BINARY_INGRESS_DRAIN_BUDGET_PACKETS) {
3491
- const state = agentBinaryIngressLanes.shift();
3492
- if (!state) {
3493
- continue;
3494
- }
3495
-
3496
- state.binaryQueueScheduled = false;
3497
- const socket = state.binaryQueueSocket;
3498
- if (state.closed || !socket || socket.destroyed) {
3499
- if (Array.isArray(state.binaryQueue)) {
3500
- state.binaryQueue.length = 0;
3501
- }
3502
- continue;
3503
- }
3504
-
3505
- const item = state.binaryQueue.shift();
3506
- if (item) {
3507
- handleAgentBinaryFrame(socket, state, item.header, item.payload);
3508
- processed += 1;
3509
- }
3510
3472
 
3511
- if (state.binaryQueue.length > 0 && !state.closed && !socket.destroyed) {
3512
- state.binaryQueueScheduled = true;
3513
- agentBinaryIngressLanes.push(state);
3514
- }
3473
+ let processed = 0;
3474
+ while (state.binaryQueue.length > 0 && processed < AGENT_BINARY_INGRESS_DRAIN_BUDGET_PACKETS) {
3475
+ const item = state.binaryQueue.shift();
3476
+ if (!item) {
3477
+ continue;
3515
3478
  }
3479
+ handleAgentBinaryFrame(socket, state, item.header, item.payload);
3480
+ processed += 1;
3481
+ }
3516
3482
 
3517
- if (agentBinaryIngressLanes.length > 0) {
3518
- drainAgentBinaryIngressRoundRobin();
3519
- }
3520
- });
3483
+ if (state.binaryQueue.length > 0 && !state.closed && !socket.destroyed) {
3484
+ scheduleAgentBinaryIngress(socket, state);
3485
+ }
3521
3486
  }
3522
3487
 
3523
3488
  function enqueueAgentBinaryFrame(socket, state, header, payload) {
package/hub/src/server.js CHANGED
@@ -20,9 +20,9 @@ const webIndexPath = resolve(webDistPath, 'index.html');
20
20
  const packageInfo = JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf8'));
21
21
  const httpHost = process.env.LIVEDESK_HUB_HTTP_HOST || '127.0.0.1';
22
22
  const httpPort = Number(process.env.LIVEDESK_HUB_HTTP_PORT || process.env.PORT || 5179);
23
- const frameBackpressureBytes = readPositiveIntegerEnv('LIVEDESK_FRAME_WS_BACKPRESSURE_BYTES', 16 * 1024 * 1024);
24
- const frameClientQueuePackets = readPositiveIntegerEnv('LIVEDESK_FRAME_WS_QUEUE_PACKETS', 64);
25
- const frameClientDrainBudgetPackets = readPositiveIntegerEnv('LIVEDESK_FRAME_WS_DRAIN_BUDGET_PACKETS', 8);
23
+ const frameBackpressureBytes = readPositiveIntegerEnv('LIVEDESK_FRAME_WS_BACKPRESSURE_BYTES', 64 * 1024 * 1024);
24
+ const frameClientQueuePackets = readPositiveIntegerEnv('LIVEDESK_FRAME_WS_QUEUE_PACKETS', 256);
25
+ const frameClientDrainBudgetPackets = readPositiveIntegerEnv('LIVEDESK_FRAME_WS_DRAIN_BUDGET_PACKETS', 64);
26
26
  const frameClients = new Set();
27
27
  const frameClientsByDeviceId = new Map();
28
28
  const frameWildcardClients = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livedesk",
3
- "version": "0.1.142",
3
+ "version": "0.1.144",
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.97",
33
+ "@livedesk/client": "0.1.98",
34
34
  "cors": "^2.8.5",
35
35
  "express": "^4.21.2",
36
36
  "path-to-regexp": "0.1.13",