tamaraRafid96
1 week ago
151
2
Laravel

laravel broadcast with pusher sends messages twice

Posted 1 week ago by tamaraRafid96

event.php

public $newTask;

public function __construct($newTask)
{
    $this->newTask = $newTask;
    $this->dontBroadcastToCurrentUser();
}


public function broadcastOn()
{
    return new PrivateChannel('user-' . Auth::id() . '-tasks');
}

channels.php

 Broadcast::channel('user-' . Auth::id() . '-tasks', function ($user, $id)
  {
if ($user->name == "tamara")
    return true;
   });

bootstrap.js

 window.Echo.private('user-' + this.user_id + '-tasks')
.listen('NewTaskAdded', e => {
    console.log("new task");
    console.log(e);
});

and i just called this ones

controller.php

    NewTaskAdded::dispatch("test");

but pusher is receiving to messages and sends it to users

Please sign in or create an account to participate in this conversation.