/** * Sets the event loop instance. * * @param \React\EventLoop\LoopInterface $loop * * @todo find some way to do a unit test for this method */ public function setLoop(LoopInterface $loop) { parent::setLoop($loop); \React\Promise\Timer\timeout(MessengerFactory::parentFromClass('PSchwisow\\Phergie\\Plugin\\Karma\\ChildProcess', $loop), 10.0, $loop)->then(function (Messenger $messenger) use($loop) { $this->logDebug('got a messenger'); $this->messenger = $messenger; $messenger->on('error', function ($e) { $this->logDebug('Error: ' . var_export($e, true)); }); $this->messenger->rpc(MessageFactory::rpc('config', $this->config))->then(function ($payload) { $this->logDebug('configuration sent to child. Response: ' . var_export($payload, true)); }); }, function ($error) { if ($error instanceof \React\Promise\Timer\TimeoutException) { // the operation has failed due to a timeout $this->logDebug('TIMEOUT'); } else { // the input operation has failed due to some other error $this->logDebug('OTHER ERROR'); } }); }
/** * Tests setLoop(). */ public function testSetLoop() { $loop = Phake::mock('\\React\\EventLoop\\LoopInterface'); $this->plugin->setLoop($loop); $this->assertSame($loop, $this->plugin->getLoop()); }
/** * Sets the event loop for the implementing class to use. * * @see \Phergie\Irc\Client\React\LoopAwareInterface::setLoop() * @param \React\EventLoop\LoopInterface $loop */ public function setLoop(LoopInterface $loop) { parent::setLoop($loop); // We have the loop, initialize listening server new Server($this); }
/** * Set Loop Interface * @param LoopInterface $loop */ public function setLoop(LoopInterface $loop) { parent::setLoop($loop); foreach ($this->plugins as $plugin) { if (!$plugin instanceof LoopAwareInterface) { continue; } $plugin->setLoop($loop); } }