1
mirror of https://github.com/comfyanonymous/ComfyUI.git synced 2025-08-02 15:04:50 +08:00

Updated to reuse session id if available

This commit is contained in:
pythongosssss
2023-03-07 13:24:15 +00:00
parent 0a0c769d6d
commit 5c55c93367
3 changed files with 25 additions and 3 deletions

View File

@@ -28,7 +28,13 @@ class ComfyApi extends EventTarget {
}
let opened = false;
this.socket = new WebSocket(`ws${window.location.protocol === "https:" ? "s" : ""}://${location.host}/ws`);
let existingSession = sessionStorage["Comfy.SessionId"] || "";
if (existingSession) {
existingSession = "?clientId=" + existingSession;
}
this.socket = new WebSocket(
`ws${window.location.protocol === "https:" ? "s" : ""}://${location.host}/ws${existingSession}`
);
this.socket.addEventListener("open", () => {
opened = true;
@@ -62,6 +68,7 @@ class ComfyApi extends EventTarget {
case "status":
if (msg.data.sid) {
this.clientId = msg.data.sid;
sessionStorage["Comfy.SessionId"] = this.clientId;
}
this.dispatchEvent(new CustomEvent("status", { detail: msg.data.status }));
break;