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))
|
hdd_led_state = operator.xor(self.__hdd_led_inverted, gpio.read(self.__hdd_led_pin))
|
||||||
else:
|
else:
|
||||||
power_led_state = hdd_led_state = False
|
power_led_state = hdd_led_state = False
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"enabled": self._enabled,
|
"enabled": self._enabled,
|
||||||
"busy": self.__region.is_busy(),
|
"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]:
|
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
||||||
|
prev_state: Dict = {}
|
||||||
while True:
|
while True:
|
||||||
if self._enabled:
|
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)
|
await asyncio.sleep(self.__state_poll)
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(60)
|
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)}
|
return {"online": bool(self.__online_shared.value)}
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
||||||
|
prev_state: Dict = {}
|
||||||
while self.is_alive():
|
while self.is_alive():
|
||||||
yield self.get_state()
|
state = self.get_state()
|
||||||
|
if state != prev_state:
|
||||||
|
yield self.get_state()
|
||||||
|
prev_state = state
|
||||||
await asyncio.sleep(self.__state_poll)
|
await asyncio.sleep(self.__state_poll)
|
||||||
|
|
||||||
@aiotools.tasked
|
@aiotools.tasked
|
||||||
|
|||||||
@ -139,8 +139,12 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
async def poll_state(self) -> AsyncGenerator[Dict, None]:
|
||||||
|
prev_state: Dict = {}
|
||||||
while True:
|
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)
|
await asyncio.sleep(self.__state_poll)
|
||||||
|
|
||||||
def get_app(self) -> str:
|
def get_app(self) -> str:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user