<?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
$i = 0;
do {
    $i++;
    $data = [
        'message' => 'Hello from the server!',
        'timestamp' => time()
    ];
    echo "data: " . json_encode($data) . "\n\n";
    ob_flush();
    flush();
    sleep(10); // Send a message every 10 seconds
}while($i <= 20 );
?>