        };

            socket.onmessage = (event) => {
                output.innerHTML += `<p>Received: ${event.data}</p>`;
            };

            socket.onclose = () => {
                output.innerHTML += '<p>Disconnected from WebSocket server</p>';
                connectBtn.disabled = false;
                disconnectBtn.disabled = true;
                sendBtn.disabled = true;
            };

            socket.onerror = (error) => {
                output.innerHTML += `<p>Error: ${error.messag