2016-07-20 9 views
0

なぜ、broadcastOn()がトリガーしていないのかわかりません。ここに私のコードです:Laravel 5.2イベントブロードキャストが起動しない

<?php 

namespace App\Events; 

use Illuminate\Queue\SerializesModels; 
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; 

class NotificationEvent extends Event implements ShouldBroadcast{ 
    use SerializesModels; 

    /** 
    * Create a new event instance. 
    * 
    * @return void 
    */ 
    public $message; 
    public $user; 
    public function __construct($user_id,$message){ 
      $this->user = $user_id; 
      $this->message = $message; 
    } 

    /** 
    * Get the channels the event should be broadcast on. 
    * 
    * @return array 
    */ 
    public function broadcastOn() 
    { 
     //var_dump("Sending event to:".'userNotifications.'.$this->user_id); 
     //return ['userNotifications.'.$this->user_id]; 
     \Log::info("broadcast notification"); 
     \Log::info($this->message); 
     return ['notifications']; 
    } 
} 

_constructのログインは機能しますが、broadcastOn()のログインは機能しません。マイ.envファイルはRedisのに設定されている

、Redisのサーバーが上にあり、ポート3001

に聞いて、これは今うまくいくかもしれない、なぜ誰でも知っていますか?

答えて

1

実際のブロードキャストはジョブです。 Laravelのジョブキューを調べてください。ジョブがphp artisan queue:workで実行されると、broadcastOn()メソッドが起動します。

+0

ありがとう、これは決して実現しませんでした。更新されていないキューワーカーが私に頭痛を与えていました:-) –

関連する問題