dimanche 10 septembre 2017

Laravel Broadcasting using Pusher with jQuery, can not trigger event

I'm trying to make a real-time application using Laravel5.5+Pusher and using Jquery as frontend development. there is my setup

BroadCast Event

class OrderSubmit implements ShouldBroadcast {

use Dispatchable, InteractsWithSockets, SerializesModels;

public $order;
public $user;


public function __construct(Order $order,User $user)
{
    $this->order = $order;
    $this->user = $user;
}


public function broadcastOn()
{
    return new PresenceChannel('order');
}

Call this Event in controller

 broadcast(new OrderSubmit($order,$order->servedBy))->toOthers();

Front End

// Enable pusher logging - don't include this in production
        Pusher.logToConsole = true;

        var pusher = new Pusher('5287d7496f9fbbd58d6d', {
            cluster: 'ap2',
            encrypted: true
        });

        var channel = pusher.subscribe('order');
        channel.bind('App\\Events\\OrderSubmit', function(data) {
            console.log(data);
        });

When i send a message from pusher debug control it's show to message instantly in my browser console, but when i try to trigger broadcast event form any controller it show me "OCCUPIED" message with beautiful orange border .

What's wrong with my code ?? enter image description here

Please do not suggest me to do that with Vue.js



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire