async def send(self, message: Message) -> None:
if self.application_state == WebSocketState.CONNECTING:<EOL><INDENT>message_type = message["<STR_LIT:type>"]<EOL>assert message_type in {"<STR_LIT>", "<STR_LIT>"}<EOL>if message_type == "<STR_LIT>":<EOL><INDENT>self.application_state = WebSocketState.DISCONNECTED<EOL><DEDENT>else:<EOL><INDENT>self.application_state = WebSocketState.CONNECTED<EOL><DEDENT>await self._send(message)<EOL><DEDENT>elif self.application_state == WebSocketState.CONNECTED:<EOL><INDENT>message_type = message["<STR_LIT:type>"]<EOL>assert message_type in {"<STR_LIT>", "<STR_LIT>"}<EOL>if message_type == "<STR_LIT>":<EOL><INDENT>self.application_state = WebSocketState.DISCONNECTED<EOL><DEDENT>await self._send(message)<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>
Send ASGI websocket messages, ensuring valid state transitions.