1
0
mirror of https://github.com/actix/examples synced 2024-11-27 16:02:57 +01:00

Fix Websockets/Chat: Prefixing Username to Messages Interferes with Server Commands (#634)

Co-authored-by: p3zq <>
This commit is contained in:
p3zq 2023-09-10 20:22:35 +01:00 committed by GitHub
parent a4c0cb22a9
commit 196cb5d8b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,10 @@ async def start_client(url: str) -> None:
# Exit with Ctrl+D # Exit with Ctrl+D
while line := await asyncio.to_thread(sys.stdin.readline): while line := await asyncio.to_thread(sys.stdin.readline):
await ws.send_str(name + ": " + line) if line.startswith("/"):
await ws.send_str(line)
else:
await ws.send_str(name + ": " + line)
dispatch_task.cancel() dispatch_task.cancel()
with suppress(asyncio.CancelledError): with suppress(asyncio.CancelledError):