connection_status example

header('Cache-Control: no-store');
        header('Content-Type: text/event-stream');
        header('Access-Control-Allow-Methods: GET');

        ob_end_clean();
        set_time_limit(0);

        $hasher  = new DirectoryHasher();
        $appHash = $hasher->hash();

        while (true) {
            if (connection_status() !== CONNECTION_NORMAL || connection_aborted()) {
                break;
            }

            $currentHash = $hasher->hash();

            // If hash has changed, tell the browser to reload.             if ($currentHash !== $appHash) {
                $appHash = $currentHash;

                $this->sendEvent('reload', ['time' => date('Y-m-d H:i:s')]);
                break;
            }
Home | Imprint | This part of the site doesn't use cookies.