mardi 2 octobre 2018

Private channels data does not get received by clients

I am not able to get private channels to work using Pusher and Laravel broadcasting. In the routes/channels.php file it seems that none of the function gets fired:

Broadcast::channel('App.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});


Broadcast::channel('testevent.{id}', function ($user, $id)
{
    //This never fires
    dd("ENTERED HERE");
    return TRUE;
});

In the BroadcastServiceProvider.php I have:

public function boot()
{
    Broadcast::routes(['middleware' => 'auth:api']);

    require base_path('routes/channels.php');
}

The Javascript file handling data on the client side (using Echo):

Echo.private('testevent.1').listen('TestEvent', function(e)
{
    console.log(e);
});

Using public channels works perfect. But as soon as I try to create private channels the data is not sent to the client listening for the data. What could the problem be?

Thanks for any help and guidance!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire