在Laravel 5.1中使用棘轮和网络插座

I'm implementing a chat inside my app, and I already got it to work locally using ratchet and websockets, but I have three doubts.

  • In order for getting it to work I need to run my server created in this script:

    <?php require __DIR__ . '/../vendor/autoload.php';
    
    use Subway\Http\Controllers\ChatController;
    use Ratchet\Server\IoServer;
    use Ratchet\Http\HttpServer;
    use Ratchet\WebSocket\WsServer;
    
    $server = IoServer::factory(new HttpServer(new WsServer(new ChatController)), 3000);
    
    $server->run();
    

    so in my terminal I need to run: php bin/server.php in order to make it work correctly. The thing is, is there a way in Laravel to start that php script when I start laravel service with php artisan serve?

  • The other doubt is that I used the local ip "127.0.0.1" just for testing purposes, but, when I get it to the server, which ip should I use?

  • For another test, I changed the local ip for my real ip which is "192.168.1.31", and a partner inside the same network, tested the chat, and we had communication with each other, but, when he gets to another section of the webpage, I automatically get disconnected, and the terminal stops running the server.php script, what could you tell me about the solution to this?

If Ratchet won't work for this implementation, I would be greatful if you could tell me how to use "Pusher" service inside laravel 5.1.

Thanks!