// WebSocket ki jagah SSE EventSource ka direct connection (Sabhi Hosting/XAMPP par chalega) const evtSource = new EventSource('stream.php'); evtSource.onmessage = (e) => { const data = JSON.parse(e.data); if (data.event === 'round_waiting') { isFlying = false; progress = 0; renderCanvas(); roundIdTxt.innerText = '#' + data.roundId; statusBadge.innerText = 'WAITING'; statusBadge.className = 'bg-yellow-600 px-2 py-0.5 rounded text-[10px] font-bold'; multiplierTxt.innerText = `NEXT ROUND IN ${data.timeLeft}s`; multiplierTxt.style.color = '#fff'; subStatusTxt.innerText = 'WAITING FOR BETS'; } if (data.event === 'multiplier_tick') { isFlying = true; roundIdTxt.innerText = '#' + data.roundId; statusBadge.innerText = 'RUNNING'; statusBadge.className = 'bg-green-600 px-2 py-0.5 rounded text-[10px] font-bold'; currentMultiplier = parseFloat(data.multiplier); multiplierTxt.innerText = currentMultiplier.toFixed(2) + 'x'; multiplierTxt.style.color = '#00e676'; subStatusTxt.innerText = ''; progress = Math.min(1, (currentMultiplier - 1) / 4); renderCanvas(); } if (data.event === 'round_crashed') { isFlying = false; statusBadge.innerText = 'CRASHED'; statusBadge.className = 'bg-red-600 px-2 py-0.5 rounded text-[10px] font-bold'; multiplierTxt.innerText = 'FLEW AWAY!'; multiplierTxt.style.color = '#ff1744'; subStatusTxt.innerText = `CRASHED AT ${data.crashPoint}x`; } }; evtSource.onerror = () => { statusBadge.innerText = 'RECONNECTING'; statusBadge.className = 'bg-red-800 px-2 py-0.5 rounded text-[10px] font-bold'; };