<?php require __DIR__ . '/../vendor/autoload.php'; $loop = React\EventLoop\Factory::create(); $inotify = new MKraemer\ReactInotify\Inotify($loop); $inotify->add('/tmp/', IN_CLOSE_WRITE | IN_CREATE | IN_DELETE); $inotify->add('/var/log/', IN_CLOSE_WRITE | IN_CREATE | IN_DELETE); $inotify->on(IN_CLOSE_WRITE, function ($path) { echo 'File closed after writing: ' . $path . PHP_EOL; }); $inotify->on(IN_CREATE, function ($path) { echo 'File created: ' . $path . PHP_EOL; }); $inotify->on(IN_DELETE, function ($path) { echo 'File deleted: ' . $path . PHP_EOL; }); $loop->run();
$cfg->requireFeatures(EventBaseConfig::FEATURE_FDS); $loop = new React\EventLoop\ExtEventLoop($cfg); $documentRoot = getcwd(); $slidesDir = $documentRoot . DIRECTORY_SEPARATOR . 'slides'; echo "Watching directory: " . $documentRoot . PHP_EOL; /* slide server and builder */ $slideBuilder = new SlideBuilder($loop, $slidesDir); $slideServer = new SlideServer($slideBuilder); /* Directory monitor */ $inotify = new MKraemer\ReactInotify\Inotify($loop); $inotify->add($documentRoot . '/slides/', IN_CREATE | IN_DELETE | IN_MODIFY); $inotify->on(IN_MODIFY, array($slideBuilder, 'buildSlides')); $inotify->on(IN_CREATE, array($slideBuilder, 'buildSlides')); $inotify->on(IN_DELETE, array($slideBuilder, 'buildSlides')); /* once slides have finished building index.html notify any connected clients to refresh */ $slideBuilder->on('slidesUpdated', array($slideServer, 'notify')); /* initialize slides */ $slideBuilder->buildSlides(); /* add contents of client side HTML that will handle auto-refreshing slides to route */ $clientBootstrap = file_get_contents(__DIR__ . '/index.html'); /*