public function run() { $this->console->writeLn("Starting server.."); $this->setState('start', $e = new observr\Event($this)); if ($e->isCanceled()) { $message = isset($e->message) ? $e->message : 'Unknown reason'; $this->console->writeLn('Server start failed.. "' . $message . '"'); } else { $this->console->writeLn('Server started.'); $this->provider->getIO()->run(); $this->console->writeLn('Shutting down..'); } }
function testEmptyEventAfter() { $user = new Mock\User(); $e = new observr\Event($user); $match = ['complete', 'success', 'complete', 'success', 'complete', 'success']; $results = []; $e->attach(observr\Event::COMPLETE, function () use(&$results) { $results[] = 'complete'; }); $e->attach(observr\Event::CANCEL, function () use(&$results) { $results[] = 'canceled'; }); $e->attach(observr\Event::FAILURE, function () use(&$results) { $results[] = 'failure'; }); $e->attach(observr\Event::SUCCESS, function () use(&$results) { $results[] = 'success'; }); $user->setState('editprofile', $e); $user->setState('logout', $e); $user->setState('login', $e); $this->assertEquals($match, $results); }
public function __construct($sender, qtcp\Network\Packet $packet) { parent::__construct($sender, ['packet' => $packet, 'data' => $packet->getData(), 'id' => $packet->getID()]); }