Handler that sends credentials in the first WebSocket message.
(websocket)
| 109 | |
| 110 | |
| 111 | async def first_message_handler(websocket): |
| 112 | """Handler that sends credentials in the first WebSocket message.""" |
| 113 | token = await websocket.recv() |
| 114 | user = get_user(token) |
| 115 | if user is None: |
| 116 | await websocket.close(CloseCode.INTERNAL_ERROR, "authentication failed") |
| 117 | return |
| 118 | |
| 119 | websocket.username = user |
| 120 | await handler(websocket) |
| 121 | |
| 122 | |
| 123 | async def query_param_auth(connection, request): |