webhooks: Add klippy state to webhooks get_status() method
Clients can now subscribe to the webhooks get_status() info to determine if the printer state changes. It is no longer needed to send a message to all clients on a shutdown transition. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
b0e3effb53
commit
1ae671f61f
|
@ -262,13 +262,6 @@ class WebHooks:
|
||||||
self.register_endpoint("emergency_stop", self._handle_estop_request)
|
self.register_endpoint("emergency_stop", self._handle_estop_request)
|
||||||
self.sconn = ServerSocket(self, printer)
|
self.sconn = ServerSocket(self, printer)
|
||||||
|
|
||||||
# Register Events
|
|
||||||
printer.register_event_handler(
|
|
||||||
"klippy:shutdown", self._notify_shutdown)
|
|
||||||
|
|
||||||
def _notify_shutdown(self):
|
|
||||||
self.call_remote_method("set_klippy_shutdown")
|
|
||||||
|
|
||||||
def register_endpoint(self, path, callback):
|
def register_endpoint(self, path, callback):
|
||||||
if path in self._endpoints:
|
if path in self._endpoints:
|
||||||
raise WebRequestError("Path already registered to an endpoint")
|
raise WebRequestError("Path already registered to an endpoint")
|
||||||
|
@ -310,10 +303,10 @@ class WebHooks:
|
||||||
self.call_remote_method(method, **kwargs)
|
self.call_remote_method(method, **kwargs)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def get_status(self, eventtime=0.):
|
def get_status(self, eventtime):
|
||||||
return {
|
state_message, state = self.printer.get_state_message()
|
||||||
"action_call_remote_method": self._action_call_remote_method
|
return {'state': state, 'state_message': state_message,
|
||||||
}
|
"action_call_remote_method": self._action_call_remote_method}
|
||||||
|
|
||||||
class GCodeHelper:
|
class GCodeHelper:
|
||||||
def __init__(self, printer):
|
def __init__(self, printer):
|
||||||
|
|
Loading…
Reference in New Issue