/**
  * Creates a new AuthServer. Start the server with start() (will block forever)
  * @param int $port the port to bind to - default 25565
  * @param string $host the host address to bind to - default 0.0.0.0
  * @param LoopInterface $loop the loop to use, default null causes Factory::create() to create one
  */
 public function __construct($port = 25565, $host = '0.0.0.0', LoopInterface $loop = null)
 {
     if (null === $loop) {
         $loop = Factory::create();
     }
     $this->loop = $loop;
     parent::__construct($loop);
     $this->certificate = new Certificate();
     $this->on('connection', [$this, 'onConnection']);
     $this->on('error', function (RuntimeException $ex) {
         echo "Error with server connection: {$ex->getMessage()}\n";
     });
     $this->listen($port, $host);
 }
Exemple #2
0
 public function __construct(LoopInterface $loop, HandlerInterface $handler)
 {
     parent::__construct($loop);
     $this->handler = $handler;
     $this->on('connection', [$this, 'onConnection']);
 }
 /**
  * Constructor
  *
  * @param LoopInterface $loop
  * @param WritableStreamInterface $stream
  * @param WritableStreamInterface $logger
  */
 public function __construct(LoopInterface $loop, WritableStreamInterface $stream, WritableStreamInterface $logger = null)
 {
     parent::__construct($loop);
     $this->stream = $stream;
     $this->logger = $logger;
 }