server/app/Console/Commands/WebSocketsServer.php
/**
     * Execute the console command.
     *
     * @return int
     */
Execute the console command.
@return int
Execute the console command . @return int
public function handle()
    {
        $loop = Factory::create();
        echo 'Starting websockets server at: ws://' . config('websockets.host') . ':' . config('websockets.port') . '/' . PHP_EOL;
        $websocketsController = new WebSocketsController();
        $websocketServer = new IoServer(
            new HttpServer(new WsServer($websocketsController)),
            new Server(config('websockets.host') . ':' . config('websockets.port'), $loop),
            $loop
        );
        $timer = $loop->addPeriodicTimer(config('game.player_move_save_timeout') / 1000, function () use ($websocketsController) {
            $websocketsController->onSave();
        });
        $loop->run();
    }
public function handle ( ) { $ loop = Factory :: create ( ) ; echo 'Starting websockets server at: ws://' . config ( 'websockets.host' ) . ':' . config ( 'websockets.port' ) . '/' . PHP_EOL ; $ websocketsController = new WebSocketsController ( ) ; $ websocketServer = new IoServer ( new HttpServer ( new WsServer ( $ websocketsController ) ) , new Server ( config ( 'websockets.host' ) . ':' . config ( 'websockets.port' ) , $ loop ) , $ loop ) ; $ timer = $ loop -> addPeriodicTimer ( config ( 'game.player_move_save_timeout' ) / 1000 , function ( ) use ( $ websocketsController ) { $ websocketsController -> onSave ( ) ; } ) ; $ loop -> run ( ) ; }
Execute the console command.
Execute the console command .
// Start websockets server // Add save timer