Esempio n. 1
0
 protected function initEvents()
 {
     $self = $this;
     $this->lEvent = event_new();
     event_set($this->lEvent, $this->handle, EV_READ | EV_PERSIST, array($this, 'handleEvent'));
     \EventPHP\Events\Loop::getInstance()->add($this->lEvent);
 }
Esempio n. 2
0
<?php

/**
 * This example simply reads and outputs the contents of stdin.
 */
spl_autoload_register(function ($className) {
    $className = str_replace("\\", '/', $className);
    include $className . '.php';
});
set_include_path('.:lib/');
use EventPHP\Streams\ReadableStream as Stream;
use EventPHP\Events\Loop;
$stream = new Stream(STDIN);
$stream->on('data', function ($data) {
    echo $data;
});
$stream->on('end', function () {
    echo "EOF reached\n";
});
Loop::getInstance()->loop();