| 114 | raise WebSocketDisconnect(message[class="st">"code"], message.get(class="st">"reason")) |
| 115 | |
| 116 | async def receive_text(self) -> str: |
| 117 | if self.application_state != WebSocketState.CONNECTED: |
| 118 | raise RuntimeError(&class="cm">#x27;WebSocket is not connected. Need to call class="st">"accept" first.') |
| 119 | message = await self.receive() |
| 120 | self._raise_on_disconnect(message) |
| 121 | return cast(str, message[class="st">"text"]) |
| 122 | |
| 123 | async def receive_bytes(self) -> bytes: |
| 124 | if self.application_state != WebSocketState.CONNECTED: |