diff --git a/anonstream/websocket.py b/anonstream/websocket.py index 38226c8..d9bb0cc 100644 --- a/anonstream/websocket.py +++ b/anonstream/websocket.py @@ -17,7 +17,8 @@ from anonstream.utils.websocket import parse_websocket_data, Malformed, WS CONFIG = current_app.config async def websocket_outbound(queue, user): - payload = { + await websocket.send_json({'type': 'ping'}) + await websocket.send_json({ 'type': 'init', 'nonce': generate_nonce(), 'title': await get_stream_title(), @@ -31,9 +32,7 @@ async def websocket_outbound(queue, user): 'scrollback': CONFIG['MAX_CHAT_SCROLLBACK'], 'digest': get_random_captcha_digest_for(user), 'pingpong': CONFIG['TASK_BROADCAST_PING'], - } - await websocket.send_json(payload) - await websocket.send_json({'type': 'ping'}) + }) while True: payload = await queue.get() if payload['type'] == 'close':