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