Esempio n. 1
0
 /**
  * @param ContainerInterface $container
  * @param $port
  * @return SocketListener
  */
 private static function makeSocketListener(ContainerInterface $container, $port)
 {
     $socketListener = new SocketListener('127.0.0.1', $port);
     $inputProcessor = new SocketInputProcessor($container);
     $socketListener->setInputProcessor($inputProcessor);
     return $socketListener;
 }
Esempio n. 2
0
function getContainerDaemon($container, $port)
{
    $socketListener = new SocketListener('127.0.0.1', $port);
    $inputProcessor = new SocketInputProcessor($container);
    $socketListener->setInputProcessor($inputProcessor);
    return new SocketDaemon($socketListener);
}
Esempio n. 3
0
 public function testRun()
 {
     $socketListener = new SocketListener('127.0.0.1', 7080);
     $this->assertFalse($socketListener->isListening());
     $phpUnit = $this;
     $socketListener->setAfterListen(function (SocketListener $listener) use($phpUnit) {
         static $tick = -1;
         $tick++;
         if (!$tick) {
             $phpUnit->assertTrue($listener->isListening());
             return true;
         }
         $listener->stop();
         $this->assertFalse($listener->isListening());
     });
     $socketListener->run();
 }