Compare commits

..

No commits in common. "09e9bdbcad7d15307600b462126e4feb263eb2e9" and "83df2a88bd00cd33256d67a04a573222eb4a4cf4" have entirely different histories.

View File

@ -1233,11 +1233,7 @@ class PromptServer():
return json_data
def send_progress_text(
self,
text: Union[bytes, bytearray, str],
node_id: str,
prompt_id: Optional[str] = None,
sid=None,
self, text: Union[bytes, bytearray, str], node_id: str, prompt_id: Optional[str] = None, sid=None
):
"""Send a progress text message to the client via WebSocket.
@ -1255,15 +1251,15 @@ class PromptServer():
text = text.encode("utf-8")
node_id_bytes = str(node_id).encode("utf-8")
# Auto-resolve sid to the currently executing client
target_sid = sid if sid is not None else self.client_id
# When prompt_id is available and client supports the new format,
# When prompt_id is provided and client supports the new format,
# prepend prompt_id as a length-prefixed field before node_id
target_sid = sid if sid is not None else self.client_id
if prompt_id and feature_flags.supports_feature(
self.sockets_metadata, target_sid, "supports_progress_text_metadata"
):
prompt_id_bytes = prompt_id.encode("utf-8")
# Pack prompt_id length as a 4-byte unsigned integer, followed by prompt_id bytes,
# then node_id length as a 4-byte unsigned integer, followed by node_id bytes, then text
message = (
struct.pack(">I", len(prompt_id_bytes))
+ prompt_id_bytes
@ -1272,6 +1268,7 @@ class PromptServer():
+ text
)
else:
# Pack the node_id length as a 4-byte unsigned integer, followed by the node_id bytes
message = struct.pack(">I", len(node_id_bytes)) + node_id_bytes + text
self.send_sync(BinaryEventTypes.TEXT, message, target_sid)
self.send_sync(BinaryEventTypes.TEXT, message, sid)