async def METHOD_NAME(self, websocket: WebSocket, message: Message) -> typing.Any:
    if self.encoding == "text":
        if "text" not in message:
            await websocket.close(code=status.WS_1003_UNSUPPORTED_DATA)
            raise RuntimeError("Expected text websocket messages, but got bytes")
        return message["text"]
    elif self.encoding == "bytes":
        if "bytes" not in message:
            await websocket.close(code=status.WS_1003_UNSUPPORTED_DATA)
            raise RuntimeError("Expected bytes websocket messages, but got text")
        return message["bytes"]
    elif self.encoding == "json":
        if message.get("text") is not None:
            text = message["text"]
        else:
            text = message["bytes"].METHOD_NAME("utf-8")
        try:
            return json.loads(text)
        except json.decoder.JSONDecodeError:
            await websocket.close(code=status.WS_1003_UNSUPPORTED_DATA)
            raise RuntimeError("Malformed JSON data received.")
    assert (
        self.encoding is None
    ), f"Unsupported 'encoding' attribute {self.encoding}"
    return message["text"] if message.get("text") else message["bytes"]