commit
This commit is contained in:
parent
2a33b5ec1f
commit
744facc233
|
|
@ -74,10 +74,12 @@ class StartWebSocketServer extends Command
|
|||
$routes = WebSocketRouter::getRoutes();
|
||||
|
||||
/** 🎩 Start the magic 🎩 */
|
||||
(new WebSocketServerFactory($routes))
|
||||
(new WebSocketServerFactory())
|
||||
->useRoutes($routes)
|
||||
->setHost($this->option('host'))
|
||||
->setPort($this->option('port'))
|
||||
->setConsoleOutput($this->output)
|
||||
->createServer()
|
||||
->run();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,16 @@ class WebSocketServerFactory
|
|||
/** @var Symfony\Component\Console\Output\OutputInterface */
|
||||
protected $consoleOutput;
|
||||
|
||||
public function __construct(RouteCollection $routes)
|
||||
public function __construct()
|
||||
{
|
||||
$this->loop = LoopFactory::create();
|
||||
}
|
||||
|
||||
public function useRoutes(RouteCollection $routes)
|
||||
{
|
||||
$this->routes = $routes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHost(string $host)
|
||||
|
|
@ -66,14 +71,7 @@ class WebSocketServerFactory
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$server = $this->createServer();
|
||||
|
||||
$server->run();
|
||||
}
|
||||
|
||||
protected function createServer(): IoServer
|
||||
public function createServer(): IoServer
|
||||
{
|
||||
$socket = new Server("{$this->host}:{$this->port}", $this->loop);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue