[请益] Laravel Broadcast + redis 问题

楼主: wuwt4y (Poky)   2018-04-10 11:56:52
环境是 ubuntu apache2 php7.1 laravel5.6 redis-cli 3.0.6
我想以laravel redis 来实现websocket
以下是我的程式码
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class ChatTest implements ShouldBroadcast
{
use InteractsWithSockets, SerializesModels;
public $username;
/**
* Create a new event instance.
*
* @param $username
*/
public function __construct($username)
{
$this->username = $username;
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
return new Channel('aabaa');
}
}
作者: crossdunk (推嘘自如)   2018-04-10 12:39:00
你确定他有推进去REDIS里面吗
楼主: wuwt4y (Poky)   2018-04-10 13:33:00
Redis::publish('aabaa', json_encode(['foo' => 'bar']))这样也可以收到,所以我想是我的ChatTest events 出问题.env BROADCAST_DRIVER=redis || QUEUE_DRIVER=redis不知道我的ChatTest 哪里出问题

Links booklink

Contact Us: admin [ a t ] ucptt.com