
            }
        }


        startBtn.addEventListener('click', async () => {
            updateStatus("连接中...");
            addLog("尝试连接到服务器...");

            try {
                const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
                websocket = new WebSocket(`${protocol}//${window.location.host}/ws?user_id=${userId}`);

                websocket.binaryType = 'arraybuffer';

                websocket.onopen = async () => {
                  