async def connect(
        self, websocket: WebSocket, mode: DataMode = DataMode.JSON
    ) -> Generator:
        """Connect to a websocket and yield data from it.

        Args:
            websocket: The websocket to connect to.
            mode: The data mode to use. Defaults to DataMode.JSON.

        Yields:
            Any: data from client side.
        """
        await websocket.accept()
        try:
            if mode == DataMode.JSON:
                yield self.iter_json(websocket)
            elif mode == DataMode.TEXT:
                yield self.iter_text(websocket)
            elif mode == DataMode.BYTES:
                yield self.iter_bytes(websocket)
            else:
                raise ValueError(f"Invalid DataMode: {mode}")
        except WebSocketDisconnect:
            logger.info("Websocket disconnected")
Connect to a websocket and yield data from it.

        Args:
            websocket: The websocket to connect to.
            mode: The data mode to use. Defaults to DataMode.JSON.

        Yields:
            Any: data from client side.
        
lanarky/websockets.py