| 121 | return cast(str, message[class="st">"text"]) |
| 122 | |
| 123 | async def receive_bytes(self) -> bytes: |
| 124 | if self.application_state != WebSocketState.CONNECTED: |
| 125 | raise RuntimeError(&class="cm">#x27;WebSocket is not connected. Need to call class="st">"accept" first.') |
| 126 | message = await self.receive() |
| 127 | self._raise_on_disconnect(message) |
| 128 | return cast(bytes, message[class="st">"bytes"]) |
| 129 | |
| 130 | async def receive_json(self, mode: str = class="st">"text") -> Any: |
| 131 | if mode not in {class="st">"text", class="st">"binary"}: |