livedesk 0.1.67 → 0.1.69
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/hub/src/server.js +65 -32
- package/package.json +2 -2
package/hub/src/server.js
CHANGED
|
@@ -28,6 +28,23 @@ let frameClientSeq = 0;
|
|
|
28
28
|
let inputClientSeq = 0;
|
|
29
29
|
let audioClientSeq = 0;
|
|
30
30
|
|
|
31
|
+
function handleRemoteHubEvent(type, event) {
|
|
32
|
+
if (type !== 'RemoteDeviceConnected') {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const deviceId = String(event?.deviceId || event?.device?.deviceId || '').trim();
|
|
36
|
+
if (!deviceId) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
for (const ws of frameClients) {
|
|
40
|
+
if (ws.readyState === 1
|
|
41
|
+
&& ws.liveDeskAutoStart
|
|
42
|
+
&& ws.liveDeskDeviceIds?.has(deviceId)) {
|
|
43
|
+
startFrameSubscriptionLive(ws, 'device-reconnected', deviceId);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
31
48
|
const remoteHub = createRemoteHub({
|
|
32
49
|
managerPackage: '@livedesk/hub',
|
|
33
50
|
managerVersion: packageInfo.version,
|
|
@@ -38,6 +55,7 @@ const remoteHub = createRemoteHub({
|
|
|
38
55
|
},
|
|
39
56
|
logEvent: (_scope, message) => console.log(`[LiveDesk Hub] ${message}`),
|
|
40
57
|
logWarn: (_scope, message) => console.warn(`[LiveDesk Hub] ${message}`),
|
|
58
|
+
emitEvent: handleRemoteHubEvent,
|
|
41
59
|
emitFrame: broadcastRemoteBinaryFrame,
|
|
42
60
|
emitAudio: broadcastRemoteBinaryAudio
|
|
43
61
|
});
|
|
@@ -185,41 +203,56 @@ function updateFrameSubscription(ws, payload = {}) {
|
|
|
185
203
|
autoStartLive: ws.liveDeskAutoStart
|
|
186
204
|
});
|
|
187
205
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
206
|
+
startFrameSubscriptionLive(ws, 'subscribe');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function startFrameSubscriptionLive(ws, reason = 'subscribe', onlyDeviceId = '') {
|
|
210
|
+
const subscribedIds = [...(ws.liveDeskDeviceIds || [])];
|
|
211
|
+
if (!ws.liveDeskAutoStart || subscribedIds.length === 0) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const targetIds = onlyDeviceId
|
|
216
|
+
? subscribedIds.filter(deviceId => deviceId === onlyDeviceId)
|
|
217
|
+
: subscribedIds;
|
|
218
|
+
if (targetIds.length === 0) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const lookup = new Map(remoteHub.listDevices({ includeDataUrl: false }).map(device => [device.deviceId, device]));
|
|
223
|
+
const started = [];
|
|
224
|
+
const skipped = [];
|
|
225
|
+
for (const deviceId of targetIds.slice(0, 80)) {
|
|
226
|
+
const device = lookup.get(deviceId);
|
|
227
|
+
const liveCapable = device?.liveStreamEnabled === true
|
|
228
|
+
|| device?.liveStreamCapable === true
|
|
229
|
+
|| device?.capabilities?.liveStream === true
|
|
230
|
+
|| device?.capabilities?.stream === true
|
|
231
|
+
|| device?.capabilities?.screenStream === true;
|
|
232
|
+
if (!device?.connected || !liveCapable) {
|
|
233
|
+
skipped.push({ deviceId, reason: device?.connected ? 'live-unavailable' : 'not-connected' });
|
|
234
|
+
continue;
|
|
215
235
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
236
|
+
const monitorIndex = Object.prototype.hasOwnProperty.call(ws.liveDeskLiveOptions.monitorSelections || {}, deviceId)
|
|
237
|
+
? ws.liveDeskLiveOptions.monitorSelections[deviceId]
|
|
238
|
+
: ws.liveDeskLiveOptions.monitorIndex;
|
|
239
|
+
const result = remoteHub.startLiveStream(deviceId, {
|
|
240
|
+
...ws.liveDeskLiveOptions,
|
|
241
|
+
monitorIndex
|
|
221
242
|
});
|
|
243
|
+
if (result?.ok) {
|
|
244
|
+
started.push({ deviceId, streamId: result.streamId, fps: result.fps, reused: result.reused === true });
|
|
245
|
+
} else {
|
|
246
|
+
skipped.push({ deviceId, reason: result?.error || 'start-failed' });
|
|
247
|
+
}
|
|
222
248
|
}
|
|
249
|
+
sendJson(ws, {
|
|
250
|
+
type: 'RemoteFrameLiveAutoStart',
|
|
251
|
+
timestamp: new Date().toISOString(),
|
|
252
|
+
reason,
|
|
253
|
+
started,
|
|
254
|
+
skipped: skipped.slice(0, 24)
|
|
255
|
+
});
|
|
223
256
|
}
|
|
224
257
|
|
|
225
258
|
function updateAudioSubscription(ws, payload = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livedesk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.69",
|
|
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.
|
|
33
|
+
"@livedesk/client": "0.1.52",
|
|
34
34
|
"cors": "^2.8.5",
|
|
35
35
|
"express": "^4.21.2",
|
|
36
36
|
"ws": "^8.18.3"
|