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); }