Пример #1
0
 /**
  * Reactor constructor.
  * @param Machine $machine
  * @param Path $path
  */
 public function __construct(Machine $machine, Path $path)
 {
     $this->buffer = new Buffer();
     $this->stock = new Dumper(new Stock($path));
     $this->loop = Factory::create();
     $this->address = $machine->getAddress();
     $this->port = $machine->getPort();
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws \Exception
  * @return boolean
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('option')) {
         // ...
     }
     $machine = new Machine($input->getArgument('machine'));
     $socket = new Connector\Socket($machine->getProtocol(), $machine->getAddress(), $machine->getPort());
     $socket->openStream();
     while (!feof($socket->socket)) {
         $contents = $socket->read(1);
         echo $contents;
     }
     return true;
 }