I have a SomeEvent.php event
So:
<?php namespace App\Events; use Illuminate\Broadcasting\Channel; use Illuminate\Queue\SerializesModels; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Contracts\Broadcasting\ShouldBroadcast; class SomeEvent implements ShouldBroadcast { use InteractsWithSockets, SerializesModels; public $data; public function __construct($array) { $this->data = $array; } public function broadcastOn() { return new PrivateChannel('channel-name'); } }
I included the following in my bootstrap.js and compiled it with gulp
import Echo from "laravel-echo" window.Echo = new Echo({ broadcaster: 'socket.io', host: 'http://site.dev:6001' }); window.Echo.private('channel-name') .listen('SomeEvent', (e) => { console.log(e); });
then I installed tlaverdure / laravel-echo-server, and here is my laravel-echo-server.json
{ "appKey": "[generated]", "authHost": "http://site.dev", "authEndpoint": "/broadcasting/auth", "database": "redis", "databaseConfig": { "redis": {}, "sqlite": { "databasePath": "/database/laravel-echo-server.sqlite" } }, "devMode": false, "host": "sitei.dev", "port": "6001", "referrers": [], "socketio": {}, "sslCertPath": "", "sslKeyPath": "" }
now when i run laravel echo server with launch laravel-echo-server, it starts very well, but when i fire the above event like
event(new SomeEvent(json_encode(['name' => 'some-name'])));
I see an event posted in redis, however nothing is written to my client console: I also include the io socket in my master.blade.php
above also happens with notifications
Any help would be greatly appreciated. Thanks guys