websockets: Add "notify_klippy_ready" notification

GIven that subscriptions are reset,  connected clients no longer maintained and they cannot check "webhooks.state" to see if Klippy is ready.  This notifcation may be used to in its place.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-11-11 17:10:13 -05:00
parent 4b2f3a6f5f
commit 3d827d7513
1 changed files with 5 additions and 0 deletions

View File

@ -170,6 +170,8 @@ class WebsocketManager:
self.rpc.register_method("server.websocket.id", self._handle_id_request) self.rpc.register_method("server.websocket.id", self._handle_id_request)
# Register events # Register events
self.server.register_event_handler(
"server:klippy_ready", self._handle_klippy_ready)
self.server.register_event_handler( self.server.register_event_handler(
"server:klippy_disconnect", self._handle_klippy_disconnect) "server:klippy_disconnect", self._handle_klippy_disconnect)
self.server.register_event_handler( self.server.register_event_handler(
@ -181,6 +183,9 @@ class WebsocketManager:
self.server.register_event_handler( self.server.register_event_handler(
"gpio_power:power_changed", self._handle_power_changed) "gpio_power:power_changed", self._handle_power_changed)
async def _handle_klippy_ready(self):
await self.notify_websockets("klippy_ready")
async def _handle_klippy_disconnect(self): async def _handle_klippy_disconnect(self):
await self.notify_websockets("klippy_disconnected") await self.notify_websockets("klippy_disconnected")