mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20:30 +08:00
send only changed states
This commit is contained in:
parent
5181b09db8
commit
67d62cd452
@ -108,7 +108,6 @@ class Atx: # pylint: disable=too-many-instance-attributes
|
||||
hdd_led_state = operator.xor(self.__hdd_led_inverted, gpio.read(self.__hdd_led_pin))
|
||||
else:
|
||||
power_led_state = hdd_led_state = False
|
||||
|
||||
return {
|
||||
"enabled": self._enabled,
|
||||
"busy": self.__region.is_busy(),
|
||||
@ -119,9 +118,13 @@ class Atx: # pylint: disable=too-many-instance-attributes
|
||||
}
|
||||
|
||||
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
||||
prev_state: Dict = {}
|
||||
while True:
|
||||
if self._enabled:
|
||||
yield self.get_state()
|
||||
state = self.get_state()
|
||||
if state != prev_state:
|
||||
yield state
|
||||
prev_state = state
|
||||
await asyncio.sleep(self.__state_poll)
|
||||
else:
|
||||
await asyncio.sleep(60)
|
||||
|
||||
@ -161,8 +161,12 @@ class Hid(multiprocessing.Process): # pylint: disable=too-many-instance-attribu
|
||||
return {"online": bool(self.__online_shared.value)}
|
||||
|
||||
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
||||
prev_state: Dict = {}
|
||||
while self.is_alive():
|
||||
state = self.get_state()
|
||||
if state != prev_state:
|
||||
yield self.get_state()
|
||||
prev_state = state
|
||||
await asyncio.sleep(self.__state_poll)
|
||||
|
||||
@aiotools.tasked
|
||||
|
||||
@ -139,8 +139,12 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
||||
}
|
||||
|
||||
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
||||
prev_state: Dict = {}
|
||||
while True:
|
||||
yield (await self.get_state())
|
||||
state = await self.get_state()
|
||||
if state != prev_state:
|
||||
yield state
|
||||
prev_state = state
|
||||
await asyncio.sleep(self.__state_poll)
|
||||
|
||||
def get_app(self) -> str:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user