[請益] 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