(self)
| 127 | return cast(str, message["text"]) |
| 128 | |
| 129 | async def receive_bytes(self) -> bytes: |
| 130 | if self.application_state != WebSocketState.CONNECTED: |
| 131 | raise WebSocketDisconnected('WebSocket is not connected. Need to call "accept" first.') |
| 132 | message = await self.receive() |
| 133 | self._raise_on_disconnect(message) |
| 134 | return cast(bytes, message["bytes"]) |
| 135 | |
| 136 | async def receive_json(self, mode: str = "text") -> Any: |
| 137 | if mode not in {"text", "binary"}: |