2016-07-15 35 views
0

我在推送器的幫助下廣播我的事件,但它運行良好,但是當我使用隊列實現時,推送器沒有收到任何廣播或可能事件不是廣播。 「M不明白的問題is.Code在下面給出,請幫我當在我們的項目中使用隊列時,事件廣播不工作

控制器功能

public function index() 
{  $this->user_id=2; 
     Event::fire(new UpdateDeviceStatus($this->user_id)); 
} 

事件文件

class UpdateDeviceStatus extends Event implements ShouldBroadcast 
{ 
    use SerializesModels; 

    /** 
    * Create a new event instance. 
    * 
    * @return void 
    */ 
    public $devices; 
    public function __construct($id) 
    { 
     $this->devices=Device::with('units')->where('user_id',$id)->get(); 
    } 

    /** 
    * Get the channels the event should be broadcast on. 
    * 
    * @return array 
    */ 
    public function broadcastOn() 
    { 
     return ['update-status']; 
    } 
} 

JS文件

Pusher.logToConsole = true; 

    var pusher = new Pusher('key', { 
     encrypted: true 
    }); 
     var channel = pusher.subscribe('update-status'); 
     channel.bind('App\\Events\\UpdateDeviceStatus', function (data) { 
      console.log(data); 

        }); 

回答

1

我有同樣的問題,並意識到,我只是忘了聽隊列:php artisan queue:listen redis

相關問題