mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-25 06:35:54 -05:00
Hooked up power events
This commit is contained in:
parent
32bc5f79fb
commit
5ad469e8b4
@ -251,6 +251,35 @@ function createMeshCore(agent) {
|
||||
return (svc);
|
||||
}
|
||||
|
||||
if (require('identifiers').isBatteryPowered && require('identifiers').isBatteryPowered())
|
||||
{
|
||||
require('MeshAgent')._battLevelChanged = function _battLevelChanged(val)
|
||||
{
|
||||
_battLevelChanged.self.SendCommand({ action: 'battery', state: _battLevelChanged.self._currentPowerState, level: val });
|
||||
};
|
||||
require('MeshAgent')._battLevelChanged.self = require('MeshAgent');
|
||||
require('MeshAgent')._powerChanged = function _powerChanged(val)
|
||||
{
|
||||
_powerChanged.self._currentPowerState = (val == 'AC' ? 'ac' : 'dc');
|
||||
_powerChanged.self.SendCommand({ action: 'battery', state: (val == 'AC' ? 'ac' : 'dc') });
|
||||
};
|
||||
require('MeshAgent')._powerChanged.self = require('MeshAgent');
|
||||
require('MeshAgent').on('Connected', function (status)
|
||||
{
|
||||
if (status == 0)
|
||||
{
|
||||
require('power-monitor').removeListener('acdc', this._powerChanged);
|
||||
require('power-monitor').removeListener('batteryLevel', this._battLevelChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
require('power-monitor').on('acdc', this._powerChanged);
|
||||
require('power-monitor').on('batteryLevel', this._battLevelChanged);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function borderController() {
|
||||
this.container = null;
|
||||
|
Loading…
Reference in New Issue
Block a user