ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Reference to the server for custom nodes + custom socket events

Open pythongosssss opened this issue 2 years ago • 1 comments

Adds instance as a property to the server as it was a simple way to achieve this Simple access to the server (with a bit of rearranging of the server creation code) would then also allow custom nodes to access the router before it is frozen to add custom routes

This allows sending + handling custom websocket messages, e.g. populating the tags here image

pythongosssss avatar Mar 26 '23 11:03 pythongosssss

Probably a good idea to document how you use your changes, and what your changes are doing besides your end goal.

WASasquatch avatar Mar 26 '23 17:03 WASasquatch

Allows custom nodes to import PromptServer and use PromptServer.instance to send websocket messages via send_sync

The client node can then listen on the frontend by importing api and adding an event listener for the name of their message

pythongosssss avatar Mar 26 '23 18:03 pythongosssss

That's pretty awesome, though since we're originating from the node itself, can't we just send the node name and deliminator (if x nodes) with the request, and have a global event handler that assigns to nodes? It seems a little hacked in, requiring both ends to utilizing your imports, etc, and define listeners, when that's almost essentially what they'd be doing even without this PR.

WASasquatch avatar Mar 26 '23 19:03 WASasquatch