Implemented update event
This commit is contained in:
@ -26,22 +26,21 @@ class MyShell extends Shell
|
||||
});
|
||||
$context->addCommand("mycommand", new MyCommand());
|
||||
$this->updatePrompt();
|
||||
|
||||
$this->addListener("update", function() {
|
||||
static $lt;
|
||||
$t = floor(microtime(true));
|
||||
if ($t > $lt) {
|
||||
$lt = $t + 5;
|
||||
echo date("Y-m-d h:i:s")."\n";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function updatePrompt()
|
||||
{
|
||||
$this->setPrompt("test[{$this->seq}]: ");
|
||||
}
|
||||
|
||||
protected function onUpdate()
|
||||
{
|
||||
static $lt;
|
||||
$t = floor(microtime(true));
|
||||
if ($t > $lt) {
|
||||
$lt = $t + 5;
|
||||
echo date("Y-m-d h:i:s")."\n";
|
||||
}
|
||||
}
|
||||
|
||||
protected function onCommand($buffer)
|
||||
{
|
||||
|
Reference in New Issue
Block a user