Let plugin listen on port 3000 to send and receive udp packets

Hello,

is there an elegant way to send and receive udp packets with a plugin to react ti it or trigger events in octoprint?

I am working on a plugin to use Octoprint confotable with Sla-printers like Elegoo Mars or Anycubic Photon.

The communication via udp is used to upload and start the print job directly from ChiTuBox.

I have already written the code for this part and it works fine. Now I just think about how to integrate it into an Octoprint plugin.

My current approach, which I haven't implemented yet, will be to start a new thread and handle the communication via udp in it.

But I'm still relatively new to Python and have a lot of questions about the Octoprint plugin system.

For example how I can trigger the start of a print job from the plugin based on my udp communication.

next i will have a look at how the discovery-plugin is built.

If anyone has some helpful approaches to the topic, please let me know.

Thanks for reading.

This may be easier once the new comm layer is implemented within OctoPrint. I know Gina's been working on it, but it's still a little ways away if I'm not mistaken.

http://docs.octoprint.org/en/master/plugins/index.html

This could be accomplished with REST API calls outside of OctoPrint, or if running from the Python side of a plugin you can trigger these types of actions. The things that you are going to be interested in long term are the hooks, specifically for event monitoring I assume.

https://wiki.python.org/moin/UdpCommunication