This commit is contained in:
Shoghi Cervantes Pueyo 2013-04-27 00:43:42 +02:00
parent d7a54123e2
commit 47e9a7b6a1

View File

@ -262,24 +262,28 @@ class ConsoleLoop extends Thread{
$line = trim(fgets($fp)); $line = trim(fgets($fp));
if($line != ""){ if($line != ""){
$this->line = $line; $this->line = $line;
$this->wait();
$this->line = false;
} }
} }
public function run(){ public function run(){
$fp = fopen("php://stdin", "r");
if(HAS_EVENT){ if(HAS_EVENT){
$this->base = new EventBase(); $this->base = new EventBase();
$this->ev = new Event($this->base, STDIN, Event::READ | Event::PERSIST, array($this, "readLine")); $this->ev = new Event($this->base, $fp, Event::READ | Event::PERSIST, array($this, "readLine"));
$this->ev->add(); $this->ev->add();
$this->base->loop(); while($this->stop === false){
$this->base->loop(EventBase::LOOP_ONCE);
if($this->line !== false){
$this->wait();
$this->line = false;
}
}
}else{ }else{
$fp = fopen("php://stdin", "r");
while($this->stop === false){ while($this->stop === false){
$this->readLine($fp); $this->readLine($fp);
} }
@fclose($fp);
} }
@fclose($fp);
exit(0); exit(0);
} }
} }