Laravel - Broadcasting - Client Events

When using Pusher Channels, you must enable the "Client Events" option in the "App Settings" section of your application dashboard in order to send client events.

Sometimes you may wish to broadcast an event to other connected clients without hitting your Laravel application at all. This can be particularly useful for things like "typing" notifications, where you want to alert users of your application that another user is typing a message on a given screen.

To broadcast client events, you may use Echo's whisper method:

    
    Echo.private(`chat.${roomId}`)
        .whisper('typing', {
            name: this.user.name
        });
	

To listen for client events, you may use the listenForWhisper method:

    
    Echo.private(`chat.${roomId}`)
        .listenForWhisper('typing', (e) => {
            console.log(e.name);
        });