I am very new laravel broadcasting. I am working with redis, socket.io and laravel echo. When i reflesh the page this is write on console
GET http://localhost:6001/socket.io/?EIO=3&transport=polling&t=MloS95c net::ERR_CONNECTION_REFUSED
My Test Event:
namespace App\Events;
use Illuminate\Broadcasting\Channel; use Illuminate\Queue\SerializesModels; use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class TestEvent {
use SerializesModels;
public $message;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($message)
{
$this->message = $message;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new Channel ('Message');
}
}
My head :
<script src="http://:6001/socket.io/socket.io.js"></script>
<meta name="csrf-token" content="">
My Controller:
public function dev(){
event(new TestEvent("Hello"));
return view('home');
}
My Js file:
window.Echo.channel(`Message`)
.listen('TestEvent', (data) => {
console.log(data);
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire