Commit Graph

18 Commits

Author SHA1 Message Date
Kevin O'Connor 16a53e6918 webhooks: Require a subscription to receive gcode output
Add a new "gcode/subscribe_output" webhook endpoint to subscribe to
gcode output.  Only client connections that subscribe to the gcode
output will receive that output.

This also moves all the gcode webhooks from gcode.py to webhooks.py
and arranges for gcode.py to be initialized prior to webhooks.py.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:20:26 -04:00
Kevin O'Connor 568393c941 webhooks: Remove "method" parameter from webhook requests
Don't require or use the "method" parameter of requests.  This
simplifies the interface.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:20:25 -04:00
Kevin O'Connor 7289af6560 webhooks: Create StatusHandler class in add_early_printer_objects()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:20:25 -04:00
Kevin O'Connor b74a5c5217 webhooks: Remove register_static_path()
Use the "info" webhook to pass critical process information back to
the caller.  The remaining users of register_static_path() can get the
required information via get_status() calls.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:20:25 -04:00
Kevin O'Connor 0aad2437c5 webhooks: Specify server_address on klippy command-line
Don't default to "/tmp/klippy_uds" for the webhooks unix domain socket
filename.  Instead, require the filename to be specified on the
command-line (via a new "-a" parameter).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-16 13:20:25 -04:00
Arksine 0c7faa978c webhooks: register gcode output handler and additional static paths
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 10:47:04 -04:00
Arksine bf221d5e26 webhooks: Implement a send buffer for socket writes
This prevents ClientConnection.send() from blocking, removing the possibility that callers become reentrant.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 10:47:04 -04:00
Arksine 4dcf494b97 webhooks: Implement unix domain socket server
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-11 10:47:04 -04:00
Arksine 27ef58642e webhooks: Implement StatusHandler class
This class provides endpoints that allow connected hosts to fetch the state of printer objects and subscribe to state "pushed" over the connection.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-06 14:30:48 -04:00
Arksine cde7e75139 webhooks: Add call_remote_method helper function
This may be used to execute formatted RPC calls.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-08-06 14:30:13 -04:00
Kevin O'Connor 795bd03b33 webhooks: Directly invoke printer.invoke_shutdown()
No need to indirectly shutdown via the gcode class - just call
printer.invoke_shutdown() directly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Kevin O'Connor 4346d37c06 webhooks: Introduce add_early_printer_objects()
Create the initial gcode class via new module level
add_early_printer_objects() function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-06 14:21:08 -04:00
Arksine 180f44b876 webhooks: fix lambda wrapper around _process_request
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-13 18:39:15 -04:00
Arksine cd8f250e84 webooks: do not connect if debuginput is enabled
Changing this check from debugoutput to debuginput allows remote applications to perform tests against Klippy without an MCU connected.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-06 12:57:50 -04:00
Arksine bfbdc04c02 webhooks: process request handlers using a Reactor Callback
This prevents _process_data from blocking and becoming reentrant.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-07-06 12:57:50 -04:00
Arksine 014c06f8a2 klippy: return message category in get_state_message()
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-06-24 19:07:33 -04:00
Arksine 2d2c09a0a3 webhooks: protect command processing from re-entry
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-06-24 19:07:33 -04:00
Arksine 475f543790 webhooks: Initial implementation
The webhooks module provides a means for Klippy to register remote API endpoints.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-06-24 19:07:33 -04:00