zombieyang / sd-ppp

Communicate between Photoshop and SD/SDForge/ComfyUI
MIT License
132 stars 6 forks source link

Add multi-user support #8

Open tianlang0704 opened 4 months ago

tianlang0704 commented 4 months ago

NOTE: This pr is based on #6. It contains #6 contents up to f2b4113 Adding support for matching multiple connected web clients and PS instances under all conditions. Under most cases, client-server-ps matching will be automatic using the information server got from the clients, and the experience will be the same as for single user, but for some special cases, a user name will need to be set.

Client-Server-PS matching logic is:

  1. If there is only one PS instance per web client IP address, all the client with the same ip address will use the one PS instance. So in most cases, which will be: local server, private remote server, even on public server, people with different public ip addresses are ok.
  2. Problem will be when multiple PS instances are under the same public ip address (VPN, behind NAT, etc), multiple users with multiple PS instances will be under the same IP address. In that case, user will have to input matching user name in ComfyUI Settings-> SD-PPP User Name, and in PS plugin, so the server knows which PS instance to use.

User name logic in detail: By default, if the ComfyUI server is run with --multi-user flag set(which may very well be if the server is shared), SD-PPP user name setting in ComfyUI settings will be set to ComfyUI's user name, so in PS plugin, the user will only have to input that User Name. If the ComfyUI is not run with --multi-user flag but still used as a shared server, user has to change the SD-PPP user name settings manually, matching the PS plugin's user name.

PS plugin: image

ComfyUI settings(Multi-User) image

ComfyUI settings(Single-User) image