2020async def _stream_file_to_ws (ws : WebSocket , entry : RoomFileEntry ) -> None :
2121 """Fetch a file from RustFS and relay every chunk to *ws*.
2222
23- Mirrors the streaming pattern in ``download.py`` — the client receives raw
23+ Mirrors the streaming pattern in ``download.py`` - the client receives raw
2424 bytes without ever knowing about the backing S3 store.
2525 """
2626 session = aioboto3 .Session ()
@@ -46,7 +46,7 @@ async def _stream_file_to_ws(ws: WebSocket, entry: RoomFileEntry) -> None:
4646 )
4747 return
4848
49- # Header — tells the client which file is coming and how large it is
49+ # Header - tells the client which file is coming and how large it is
5050 await ws .send_text (
5151 json .dumps (
5252 {
@@ -58,14 +58,14 @@ async def _stream_file_to_ws(ws: WebSocket, entry: RoomFileEntry) -> None:
5858 )
5959 )
6060
61- # Binary chunks — same as ``async for chunk in s3_response["Body"]``
61+ # Binary chunks - same as ``async for chunk in s3_response["Body"]``
6262 try :
6363 async for chunk in s3_response ["Body" ]:
6464 await ws .send_bytes (chunk )
6565 finally :
6666 s3_response ["Body" ].close ()
6767
68- # Footer — signals the client that this file is complete
68+ # Footer - signals the client that this file is complete
6969 await ws .send_text (json .dumps ({"type" : "file_end" , "key" : entry .key }))
7070
7171
@@ -87,15 +87,15 @@ async def room_ws(ws: WebSocket, room_id: str, host_token: str | None = None):
8787
8888 await ws .accept ()
8989
90- # ── subscribe FIRST so no events are lost between snapshot and listen ──
90+ # subscribe FIRST so no events are lost between snapshot and listen
9191 sub_client = aioredis .from_url (
9292 settings .REDIS_ENDPOINT , encoding = "utf-8" , decode_responses = True
9393 )
9494 pubsub = sub_client .pubsub ()
9595 channel = RoomState .channel_for (room_id )
9696 await pubsub .subscribe (channel )
9797
98- # ── snapshot (re-read after subscribe to guarantee consistency) ───
98+ # snapshot (re-read after subscribe to guarantee consistency)
9999 room = await RoomState .get (room_id )
100100 if room is None :
101101 await pubsub .unsubscribe (channel )
@@ -137,14 +137,14 @@ async def _listen_events() -> None:
137137 except Exception :
138138 continue
139139
140- # Host destroyed the room — notify client and close
140+ # Host destroyed the room - notify client and close
141141 if data .get ("type" ) == "room_destroyed" :
142142 await ws .send_text (json .dumps ({"type" : "room_destroyed" }))
143143 file_queue .put_nowait (None )
144144 await ws .close (code = 4001 , reason = "Room destroyed by host" )
145145 return
146146
147- # Host count changed — forward directly
147+ # Host count changed - forward directly
148148 if data .get ("type" ) == "host_count" :
149149 await ws .send_text (json .dumps (data ))
150150 continue
@@ -157,7 +157,7 @@ async def _listen_events() -> None:
157157
158158 if event .event == "file_added" :
159159 if event .file .key in seen_keys :
160- # Already queued from the snapshot — skip duplicate
160+ # Already queued from the snapshot - skip duplicate
161161 continue
162162 seen_keys .add (event .file .key )
163163 file_queue .put_nowait (event .file )
@@ -174,7 +174,7 @@ async def _listen_events() -> None:
174174 except WebSocketDisconnect , asyncio .CancelledError :
175175 pass
176176
177- # ── streamer — pulls from queue and streams one file at a time ───
177+ # pulls from queue and streams one file at a time
178178 async def _stream_queued_files () -> None :
179179 try :
180180 while True :
@@ -189,7 +189,7 @@ async def _stream_queued_files() -> None:
189189 stream_task = asyncio .create_task (_stream_queued_files ())
190190
191191 try :
192- # Keep alive — read (and discard) client pings / messages
192+ # Keep alive - read (and discard) client pings / messages
193193 while True :
194194 await ws .receive_text ()
195195 except WebSocketDisconnect :
0 commit comments