&& window.gameWS.ws && window.gameWS.ws.readyState === WebSocket.OPEN) {
                window.canvasGame.setWebSocket(window.gameWS.ws);
                console.log('Canvas game connected to WebSocket');
                return true;
            }
            return false;
        }

        // Try to connect immediately
        if (!connectCanvasToWebSocket()) {
            // If not ready, wait and retry
            const checkConnection = setInterval(() => {
                if (connectCanvasToWebSocket(