wip
This commit is contained in:
parent
59aad53091
commit
a09356e40c
|
|
@ -3,8 +3,6 @@
|
|||
namespace BeyondCode\LaravelWebSockets;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Routing\Router as LaravelRouter;
|
||||
use BeyondCode\LaravelWebSockets\Facades\WebSocketRouter;
|
||||
|
||||
class LaravelWebSocketsServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -13,10 +11,6 @@ class LaravelWebSocketsServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
LaravelRouter::macro('websocket', function($uri, $action) {
|
||||
WebSocketRouter::addRoute($uri, $action);
|
||||
});
|
||||
|
||||
$this->commands([
|
||||
Console\StartWebSocketServer::class,
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -17,12 +17,23 @@ class Router
|
|||
$this->routes = new RouteCollection;
|
||||
}
|
||||
|
||||
public function addRoute($uri, $action)
|
||||
/**
|
||||
* Add a new WebSocket route.
|
||||
*
|
||||
* @param $uri
|
||||
* @param $action
|
||||
*/
|
||||
public function websocket($uri, $action)
|
||||
{
|
||||
if (!is_subclass_of($action, WebSocketController::class)) {
|
||||
throw InvalidWebSocketController::withController($action);
|
||||
}
|
||||
|
||||
$this->addRoute($uri, $action);
|
||||
}
|
||||
|
||||
public function addRoute($uri, $action)
|
||||
{
|
||||
$this->routes->add($uri, $this->getRoute($uri, $action));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue