Try to ensure websocket is closed when forgetting about it
Might not be necessary, but if it is then it prevents a sitation where a websocket is still open but we've forgotten about it, so we will never broadcast any new messages to it and the client will be practically frozen in time until they disconnect and open a new websocket. Also update the user's last_seen when the websocket is closed. This prevents a user with js enabled who's actually idle being considered absent and being rotated when their websocket accidentally closes for a few seconds.
このコミットが含まれているのは:
コミット
4eaf9b56f7
|
@ -5,6 +5,7 @@ import asyncio
|
||||||
|
|
||||||
from quart import current_app, websocket
|
from quart import current_app, websocket
|
||||||
|
|
||||||
|
from anonstream.user import see
|
||||||
from anonstream.websocket import websocket_outbound, websocket_inbound
|
from anonstream.websocket import websocket_outbound, websocket_inbound
|
||||||
from anonstream.routes.wrappers import with_user_from
|
from anonstream.routes.wrappers import with_user_from
|
||||||
|
|
||||||
|
@ -19,4 +20,9 @@ async def live(user):
|
||||||
try:
|
try:
|
||||||
await asyncio.gather(producer, consumer)
|
await asyncio.gather(producer, consumer)
|
||||||
finally:
|
finally:
|
||||||
|
see(user)
|
||||||
user['websockets'].remove(queue)
|
user['websockets'].remove(queue)
|
||||||
|
try:
|
||||||
|
await websocket.close(1000)
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
|
読み込み中…
新しいイシューから参照