This repository has been archived on 2023-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
web/public/race/stream.php
2022-03-23 10:08:36 +01:00

30 lines
559 B
PHP

<?php $app = require '../../app/inc.php';
use App\Timetable\TimeMapper;
use App\SSE\Sender;
$timeMapper = new TimeMapper($app->database->conn);
/**
* Server-Sent Events (SSE)
*/
$sse = new Sender();
$last_change_in_timetable;
while (!connection_aborted())
{
$time = $timeMapper->getLatest();
if ($time)
{
$last_change_in_timetable = $time->date->getTimestamp();
if ($last_time == NULL || $last_change_in_timetable > $last_ajax_call)
{
$sse->send($timeMapper->getAll());
}
}
sleep(1);
}