L
L
lucifer_jr2018-05-20 14:38:09
Google Chrome
lucifer_jr, 2018-05-20 14:38:09

Problem with broadcasting in frontend?

5b015d94b9baa942276233.png
code in bootstrap.js

import Echo from 'laravel-echo'

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: '....',
});

window.Echo.channel('chat-room')
    .listen('.app.Events.ChatMessageWasReceived.php', (e)=>{
   console.log(e);
});

the event itself
class ChatMessageWasReceived implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $chatMessage;
    public $user;

    /**
     * Create a new event instance.
     *
     * @param $user
     * @param $chatMessage
     */
    public function __construct($chatMessage, $user)
    {
        $this->user = $user;
        $this->chatMessage = $chatMessage;
    }

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

and the problem is that an event message comes to the service, but in chrome it does not trigger in any way. And I can not understand what is robelma. Need help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question