34 lines
685 B
PHP
34 lines
685 B
PHP
<?php $app = require '../../app/inc.php';
|
|
|
|
use App\Teamtable\TeamMapper;
|
|
use App\Timetable\TimeMapper;
|
|
use App\SSE\Sender;
|
|
|
|
$teamMapper = new TimeMapper($app->database->conn);
|
|
$timeMapper = new TimeMapper($app->database->conn);
|
|
|
|
/**
|
|
* Server-Sent Events (SSE)
|
|
*/
|
|
$sse = new Sender();
|
|
$sse->start();
|
|
|
|
$prev_last_insert = NULL;
|
|
while (!connection_aborted())
|
|
{
|
|
$time = $timeMapper->getLatest();
|
|
|
|
if ($time)
|
|
{
|
|
$last_insert = $time->date->getTimestamp();
|
|
|
|
if ($prev_last_insert == NULL || $last_insert > $prev_last_insert)
|
|
{
|
|
$sse->flush($timeMapper->getAll());
|
|
|
|
$prev_last_insert = $last_insert;
|
|
}
|
|
}
|
|
|
|
sleep(1);
|
|
} |