fix: Manual checking for system info to fix bug in library
This commit is contained in:
parent
816d50ae4d
commit
a7eb655a48
1 changed files with 10 additions and 19 deletions
|
|
@ -65,10 +65,6 @@ export const system = new Elysia({ prefix: '/api/system' })
|
||||||
response: SystemInfoSchema,
|
response: SystemInfoSchema,
|
||||||
async open (ws)
|
async open (ws)
|
||||||
{
|
{
|
||||||
const valuesObject = {
|
|
||||||
battery: 'percent, isCharging, acConnected, hasBattery'
|
|
||||||
};
|
|
||||||
|
|
||||||
const battery = await si.battery();
|
const battery = await si.battery();
|
||||||
const wifi = await si.wifiConnections();
|
const wifi = await si.wifiConnections();
|
||||||
const bluetooth = await si.bluetoothDevices();
|
const bluetooth = await si.bluetoothDevices();
|
||||||
|
|
@ -78,28 +74,23 @@ export const system = new Elysia({ prefix: '/api/system' })
|
||||||
bluetoothDevices: bluetooth
|
bluetoothDevices: bluetooth
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
(ws.data as any).observer = si.observe(valuesObject, 1000 * 30, (data) =>
|
(ws.data as any).observer = setInterval(async () =>
|
||||||
{
|
{
|
||||||
ws.send(data);
|
const battery = await si.battery();
|
||||||
});
|
const wifi = await si.wifiConnections();
|
||||||
|
const bluetooth = await si.bluetoothDevices();
|
||||||
|
ws.send({
|
||||||
|
battery: battery,
|
||||||
|
wifiConnections: wifi,
|
||||||
|
bluetoothDevices: bluetooth
|
||||||
|
}, true);
|
||||||
|
}, 1000 * 30);
|
||||||
},
|
},
|
||||||
close (ws)
|
close (ws)
|
||||||
{
|
{
|
||||||
clearInterval((ws.data as any).observer);
|
clearInterval((ws.data as any).observer);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.get('/info/battery', async () =>
|
|
||||||
{
|
|
||||||
return si.battery();
|
|
||||||
})
|
|
||||||
.get('/info/wifi', async () =>
|
|
||||||
{
|
|
||||||
return si.wifiConnections();
|
|
||||||
})
|
|
||||||
.get('/info/bluetooth', async () =>
|
|
||||||
{
|
|
||||||
return si.bluetoothDevices();
|
|
||||||
})
|
|
||||||
.get('/drives', async () =>
|
.get('/drives', async () =>
|
||||||
{
|
{
|
||||||
const drives = await getDevices();
|
const drives = await getDevices();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue