This commit is contained in:
+37
-3
@@ -52,8 +52,9 @@ export async function serveOnSessionBus(daemon) {
|
|||||||
ComputerStep(json) { this.emit('ComputerStep', String(json)); }
|
ComputerStep(json) { this.emit('ComputerStep', String(json)); }
|
||||||
ComputerHighlight(json) { this.emit('ComputerHighlight', String(json)); }
|
ComputerHighlight(json) { this.emit('ComputerHighlight', String(json)); }
|
||||||
}
|
}
|
||||||
Interface.configureMembers(Session, {
|
Session.configureMembers({
|
||||||
Arm: { inSignature: '', outSignature: '', method: 'Arm' },
|
methods: {
|
||||||
|
Arm: { inSignature: '', outSignature: '' },
|
||||||
Sleep: { inSignature: '', outSignature: '', method: 'Sleep' },
|
Sleep: { inSignature: '', outSignature: '', method: 'Sleep' },
|
||||||
Shutdown: { inSignature: '', outSignature: '', method: 'Shutdown' },
|
Shutdown: { inSignature: '', outSignature: '', method: 'Shutdown' },
|
||||||
PushToTalk: { inSignature: 'b', outSignature: '', method: 'PushToTalk' },
|
PushToTalk: { inSignature: 'b', outSignature: '', method: 'PushToTalk' },
|
||||||
@@ -71,7 +72,9 @@ export async function serveOnSessionBus(daemon) {
|
|||||||
AssessModelFit: { inSignature: 's', outSignature: 's', method: 'AssessModelFit' },
|
AssessModelFit: { inSignature: 's', outSignature: 's', method: 'AssessModelFit' },
|
||||||
DownloadModel: { inSignature: 's', outSignature: 's', method: 'DownloadModel' },
|
DownloadModel: { inSignature: 's', outSignature: 's', method: 'DownloadModel' },
|
||||||
CancelModel: { inSignature: 's', outSignature: 's', method: 'CancelModel' },
|
CancelModel: { inSignature: 's', outSignature: 's', method: 'CancelModel' },
|
||||||
WipeComputerTraces: { inSignature: '', outSignature: 'b', method: 'WipeComputerTraces' },
|
WipeComputerTraces: { inSignature: '', outSignature: 'b' },
|
||||||
|
},
|
||||||
|
signals: {
|
||||||
StateChanged: { signature: 's', signal: true },
|
StateChanged: { signature: 's', signal: true },
|
||||||
Reply: { signature: 's', signal: true },
|
Reply: { signature: 's', signal: true },
|
||||||
Token: { signature: 's', signal: true },
|
Token: { signature: 's', signal: true },
|
||||||
@@ -86,8 +89,39 @@ export async function serveOnSessionBus(daemon) {
|
|||||||
ComputerStep: { signature: 's', signal: true },
|
ComputerStep: { signature: 's', signal: true },
|
||||||
ComputerHighlight: { signature: 's', signal: true },
|
ComputerHighlight: { signature: 's', signal: true },
|
||||||
ConfirmationRequired: { signature: 'sss', signal: true },
|
ConfirmationRequired: { signature: 'sss', signal: true },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const bus = dbus.sessionBus();
|
const bus = dbus.sessionBus();
|
||||||
|
// Bare streams emit `data` but do not keep a Node-style readable buffer.
|
||||||
|
// dbus-next's authentication and message parser use read()/readable, so
|
||||||
|
// provide that small compatibility layer for this one D-Bus connection.
|
||||||
|
const stream = bus._connection?.stream;
|
||||||
|
if (globalThis.Bare && stream && !stream.__jarvisReadableBuffer) {
|
||||||
|
let pending = Buffer.alloc(0);
|
||||||
|
let readableScheduled = false;
|
||||||
|
stream.__jarvisReadableBuffer = true;
|
||||||
|
stream.on('data', (chunk) => {
|
||||||
|
pending = Buffer.concat([pending, Buffer.from(chunk)]);
|
||||||
|
if (!readableScheduled) {
|
||||||
|
readableScheduled = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
readableScheduled = false;
|
||||||
|
stream.emit('readable');
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
stream.read = (size) => {
|
||||||
|
if (pending.length === 0) return null;
|
||||||
|
if (size == null || size >= pending.length) {
|
||||||
|
const result = pending;
|
||||||
|
pending = Buffer.alloc(0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
const result = pending.subarray(0, size);
|
||||||
|
pending = pending.subarray(size);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}
|
||||||
await bus.requestName(BUS_NAME);
|
await bus.requestName(BUS_NAME);
|
||||||
const iface = new Session();
|
const iface = new Session();
|
||||||
bus.export(OBJECT, iface);
|
bus.export(OBJECT, iface);
|
||||||
|
|||||||
Reference in New Issue
Block a user