websockets: Add metadata update notification

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-08-30 15:30:38 -04:00
parent bcb7e17105
commit 2c5bb4710e
1 changed files with 5 additions and 0 deletions

View File

@ -115,6 +115,8 @@ class WebsocketManager:
"server:status_update", self._handle_status_update) "server:status_update", self._handle_status_update)
self.server.register_event_handler( self.server.register_event_handler(
"file_manager:filelist_changed", self._handle_filelist_changed) "file_manager:filelist_changed", self._handle_filelist_changed)
self.server.register_event_handler(
"file_manager:metadata_update", self._handle_metadata_update)
async def _handle_klippy_disconnect(self): async def _handle_klippy_disconnect(self):
await self.notify_websockets("klippy_disconnected") await self.notify_websockets("klippy_disconnected")
@ -128,6 +130,9 @@ class WebsocketManager:
async def _handle_filelist_changed(self, flist): async def _handle_filelist_changed(self, flist):
await self.notify_websockets("filelist_changed", flist) await self.notify_websockets("filelist_changed", flist)
async def _handle_metadata_update(self, metadata):
await self.notify_websockets("metadata_update", metadata)
def register_handler(self, api_def, callback=None): def register_handler(self, api_def, callback=None):
for r_method in api_def.request_methods: for r_method in api_def.request_methods:
cmd = r_method.lower() + '_' + api_def.ws_method cmd = r_method.lower() + '_' + api_def.ws_method