0

I'm making an app with 2 different frameworks, Laravel 5.5 and Vuetify 1.5 (Vuejs 2.0). Now I'm trying to make broadcast events dispatched from laravel app using pusher and to make vuetify project listen it but... There is the problem.

My intention is to create service worker to listen the private channel and dispatch local notification on listen that event. But I couldn't do the first step, to listen the event.

  • How can I listen events dispatched from private channel by laravel app from another javascript framework?
5
  • github.com/socketio/socket.io-client Commented Apr 23, 2018 at 9:35
  • laravel.com/docs/5.6/broadcasting Commented Apr 23, 2018 at 9:35
  • I read the laravel docs of broadcasting 3 or 4 times today. The problem is that I'm trying to listen private channel, and to do this I need to authenticate. But I will try to use socketio and public channel because now I'm using pusher with private channel. Commented Apr 23, 2018 at 9:44
  • 1
    Did you try laravel echo server? It supports auth and private channels. Uses socket.io also. Commented Apr 23, 2018 at 9:47
  • @DigitalDrifter I will try it. Thanks Commented Apr 23, 2018 at 9:54

1 Answer 1

2

VueJs

  window.Echo.channel("channel-name").listen(".channel-app", e => {
    console.log(e);
 });

Laravel

Event

public function broadcastOn()
{
    return new Channel('channel-name');
}

public function broadcastAs()
{
    return 'channel-app';
}

Controller

public function test()
{
    broadcast(new MessageSent());
}

channel

Broadcast::channel('channel-name', function(){ return true; });
Sign up to request clarification or add additional context in comments.

1 Comment

where will I put this channel "Broadcast::channel('channel-name', function(){ return true; });"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.