本文整理汇总了PHP中React\Socket\Server::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::__construct方法的具体用法?PHP Server::__construct怎么用?PHP Server::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类React\Socket\Server
的用法示例。
在下文中一共展示了Server::__construct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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);
}
示例2: __construct
public function __construct(LoopInterface $loop, HandlerInterface $handler)
{
parent::__construct($loop);
$this->handler = $handler;
$this->on('connection', [$this, 'onConnection']);
}
示例3: __construct
/**
* 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;
}