Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #324
    dan
    Participant

    This is for a chat application, I am using Laravel Echo and Laravel Websockets. I am pretty sure websocket is working because the event is logged in laravel-websocket dashboard.

    This is the Livewire Component that BroadCast the Event:

    public function reply() {

    broadcast(new MessageAdded($message))->toOthers();

    }

    This is the LiveWire Component that listens to the broadcasted Event:

    public function getListeners() {
    return [

    “echo-private:conversations, .MessageAdded” => ‘messageAdded’,
    ];
    }

    public function messageAdded()
    {
    dd(‘A message has been added’)
    }

    The thing is that when the event is broadcasted I could see it reflected in the laravel-websockets dashboard but it wont fire the function messageAdded() which means the Livewire component is not detecting the Event Broadcasted.

    Is it a Livewire problem or maybe a Laravel Echo problem.

    #325
    dan
    Participant

    Never mind. It actually works.

    Since I used toOthers() method, messageAdded() is not going to fire on my browser since I am the authenticated user and the method will only fire to other users. When I open another browser and use a different authenticated user, the messaAdded method will fire off.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.