mardi 10 septembre 2019

Laravel : there is a listening problem in my console

i install laravel 5 and socket.io unfortunately i have no answer to my listener in the console of my browser.

I tried all the tips of the web. a lot of people have the same problem but I have not seen a solution or for me it's not right

bootstrap.js


window.io = require('socket.io-client');

let e = new Echo({
    broadcaster: 'socket.io',
    host: window.location.hostname + ':6001'
})

e.channel('orders')
    .listen('DashboardEvent', function(e) {
        console.log('DashboardEvent', 'test') <- not listening in my console
    })

routes

Route::get('/test',function (){
    broadcast (new DashboardEvent('route'));
    return 'broadcasted' ;

});

Event/DashboardEvent

class DashboardEvent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $orders;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($orders)
    {
        $this->orders = $orders;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('orders');
    }


vue.blade

<script src="//:6001/socket.io/socket.io.js"></script>
<script src=""defer></script>

laravelechoserver.json

"devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "redis",
    "socketio": {},
    "secureOptions": 67108864,
    "sslCertPath": "",
    "sslKeyPath": "",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": {
        "http": true,
        "redis": true
    },
    "apiOriginAllow": {
        "allowCors": true,
        "allowOrigin": "y",
        "allowMethods": "GET, POST",
        "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
    }



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2LKvRma
via IFTTT

Aucun commentaire:

Enregistrer un commentaire