【发布时间】:2016-03-30 09:33:29
【问题描述】:
我正在开发一个应用来处理视频。我尝试将 10 个视频推送到队列中。处理完视频后,我触发了这样一个事件:
...
$production->render();
event(new VideoHasProcessed(basename($this->video->path)));
...
我会关注这个视频向用户推送通知 (https://laracasts.com/series/whats-new-in-laravel-5-1/episodes/12)
问题是:我想在处理每个视频时推送通知,但实际上,在处理了 10 个视频后才显示通知。
这是我的脚本:
<script>
(function () {
var pusher = new Pusher(PUSHER_ID, {
encrypted: true
});
var channel = pusher.subscribe('test');
channel.bind('App\\Events\\VideoHasProcessed', function(data) {
console.log(data);
});
})();
</script>
更新:
派遣工作
foreach ($request->input('files') as $file)
{
...
// Dispatch a job.
$this->dispatch(new ProduceVideo($video));
....
}
还有我的工作类别:
公共函数句柄(ProductionRepository $production) { ...
$production->render();
event(new VideoHasProcessed(basename($this->video->path)));
...
}
【问题讨论】:
标签: laravel queue broadcast pusher