From 83c24ff765e622a030d9220367b8e82119ee0517 Mon Sep 17 00:00:00 2001 From: Arksine Date: Wed, 17 Feb 2021 08:15:07 -0500 Subject: [PATCH] moonraker: register notifications via the websocket's "register_notification" method Signed-off-by: Eric Callahan --- moonraker/moonraker.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/moonraker/moonraker.py b/moonraker/moonraker.py index 133b3a9..d0538aa 100755 --- a/moonraker/moonraker.py +++ b/moonraker/moonraker.py @@ -81,6 +81,12 @@ class Server: self.register_endpoint( "/server/restart", ['POST'], self._handle_server_restart) + self.register_notification("server:klippy_ready") + self.register_notification("server:klippy_shutdown") + self.register_notification("server:klippy_disconnect", + "klippy_disconnected") + self.register_notification("server:gcode_response") + # Setup remote methods accessable to Klippy. Note that all # registered remote methods should be of the notification type, # they do not return a response to Klippy after execution @@ -166,6 +172,10 @@ class Server: raise ServerError(f"Plugin ({plugin_name}) not found") return plugin + def register_notification(self, event_name, notify_name=None): + wsm = self.moonraker_app.get_websocket_manager() + wsm.register_notification(event_name, notify_name) + def register_event_handler(self, event, callback): self.events.setdefault(event, []).append(callback)