使用laravel pusher进行广播异常

时间:2017-09-10 09:52:21

标签: laravel-5.4 pusher

我使用推杆和laravel 5.4。 我安装了推杆使用: 作曲家需要pusher / pusher-php-server" ~2.6" 之后,我在.env,config / App.php和config / Broadcasting.php中进行必要的更改。我创建了TaskEvent:

<?php
namespace App\Events;

use Illuminate\Broadcasting\Channel;

use Illuminate\Queue\SerializesModels;

use Illuminate\Broadcasting\PrivateChannel;

use Illuminate\Broadcasting\PresenceChannel;

use Illuminate\Foundation\Events\Dispatchable;

use Illuminate\Broadcasting\InteractsWithSockets;

use Illuminate\Contracts\Broadcasting\ShouldBroadcast;


class TaskEvent implements ShouldBroadcast

{

  use Dispatchable, InteractsWithSockets, SerializesModels;

    /**
     * Create a new event instance.
     *
     * @return void
     */

    public $message;
    public function __construct($message)
    {
        $this->message=$message;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('testChannel');
    }
}

然后,在routes / web.php中:

use App\Events\TaskEvent;

Route::get('event',function(){
    event(new TaskEvent('hello world'));
});

但我收到此错误:

(1/1) BroadcastException

in PusherBroadcaster.php (line 106)

请帮帮我!!!

0 个答案:

没有答案