spoolman: add a status notification
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
a5128f06ad
commit
d410731faa
|
@ -79,6 +79,7 @@ class SpoolManager:
|
||||||
|
|
||||||
def _register_notifications(self):
|
def _register_notifications(self):
|
||||||
self.server.register_notification("spoolman:active_spool_set")
|
self.server.register_notification("spoolman:active_spool_set")
|
||||||
|
self.server.register_notification("spoolman:spoolman_status_changed")
|
||||||
|
|
||||||
def _register_listeners(self):
|
def _register_listeners(self):
|
||||||
self.server.register_event_handler(
|
self.server.register_event_handler(
|
||||||
|
@ -140,6 +141,7 @@ class SpoolManager:
|
||||||
self._cancel_spool_check_task()
|
self._cancel_spool_check_task()
|
||||||
coro = self._check_spool_deleted()
|
coro = self._check_spool_deleted()
|
||||||
self.spool_check_task = self.eventloop.create_task(coro)
|
self.spool_check_task = self.eventloop.create_task(coro)
|
||||||
|
self._send_status_notification()
|
||||||
await self._read_messages()
|
await self._read_messages()
|
||||||
log_connect = True
|
log_connect = True
|
||||||
last_err = Exception()
|
last_err = Exception()
|
||||||
|
@ -166,6 +168,8 @@ class SpoolManager:
|
||||||
f"Server Ping Time Elapsed: {ping_time}"
|
f"Server Ping Time Elapsed: {ping_time}"
|
||||||
)
|
)
|
||||||
self.spoolman_ws = None
|
self.spoolman_ws = None
|
||||||
|
if not self.is_closing:
|
||||||
|
self._send_status_notification()
|
||||||
break
|
break
|
||||||
|
|
||||||
def _decode_message(self, message: str) -> None:
|
def _decode_message(self, message: str) -> None:
|
||||||
|
@ -370,6 +374,12 @@ class SpoolManager:
|
||||||
"spool_id": self.spool_id
|
"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):
|
async def close(self):
|
||||||
self.is_closing = True
|
self.is_closing = True
|
||||||
self.report_timer.stop()
|
self.report_timer.stop()
|
||||||
|
|
Loading…
Reference in New Issue