spoolman: add a status notification

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2024-01-20 11:48:53 -05:00
parent a5128f06ad
commit d410731faa
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 10 additions and 0 deletions

View File

@ -79,6 +79,7 @@ class SpoolManager:
def _register_notifications(self):
self.server.register_notification("spoolman:active_spool_set")
self.server.register_notification("spoolman:spoolman_status_changed")
def _register_listeners(self):
self.server.register_event_handler(
@ -140,6 +141,7 @@ class SpoolManager:
self._cancel_spool_check_task()
coro = self._check_spool_deleted()
self.spool_check_task = self.eventloop.create_task(coro)
self._send_status_notification()
await self._read_messages()
log_connect = True
last_err = Exception()
@ -166,6 +168,8 @@ class SpoolManager:
f"Server Ping Time Elapsed: {ping_time}"
)
self.spoolman_ws = None
if not self.is_closing:
self._send_status_notification()
break
def _decode_message(self, message: str) -> None:
@ -370,6 +374,12 @@ class SpoolManager:
"spool_id": self.spool_id
}
def _send_status_notification(self) -> None:
self.server.send_event(
"spoolman:spoolman_status_changed",
{"spoolman_connected": self.ws_connected}
)
async def close(self):
self.is_closing = True
self.report_timer.stop()