From cde7e75139b29a89a9f6a5140826464c5223faff Mon Sep 17 00:00:00 2001 From: Arksine Date: Tue, 4 Aug 2020 17:18:36 -0400 Subject: [PATCH] webhooks: Add call_remote_method helper function This may be used to execute formatted RPC calls. Signed-off-by: Eric Callahan --- klippy/webhooks.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/klippy/webhooks.py b/klippy/webhooks.py index f6491187..1525bc42 100644 --- a/klippy/webhooks.py +++ b/klippy/webhooks.py @@ -268,5 +268,17 @@ class WebHooks: raise WebRequestError(msg) return cb + def call_remote_method(self, method, **kwargs): + self.sconn.send({'method': method, 'params': kwargs}) + + def _action_call_remote_method(self, method, **kwargs): + self.call_remote_method(method, **kwargs) + return "" + + def get_status(self, eventtime=0.): + return { + "action_call_remote_method": self._action_call_remote_method + } + def add_early_printer_objects(printer): printer.add_object('webhooks', WebHooks(printer))