[請益] Laravel Broadcast + redis 問題
環境是 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');
}
}
--------------------------------------------------
routes/channels.php
Broadcast::channel('aabaa', true);
--------------------------------------------------
我直接bash
用redis-cli 監聽 頻道 aabaa
但是無論我怎麼觸發事件
Route::get('/publish', function () {
event(new App\Events\ChatTest('ff'));
return 'event';
});
都沒有收到任何消息
當然直接用redis-cli 推 會收到
不曉得是哪裡出了問題?
還請各位高手指點迷津
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.34.127.221
※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1523332614.A.0C8.html
推
04/10 12:39,
6年前
, 1F
04/10 12:39, 1F
→
04/10 13:33,
6年前
, 2F
04/10 13:33, 2F
→
04/10 13:33,
6年前
, 3F
04/10 13:33, 3F
→
04/10 13:34,
6年前
, 4F
04/10 13:34, 4F
→
04/10 13:34,
6年前
, 5F
04/10 13:34, 5F
→
04/11 10:01,
6年前
, 6F
04/11 10:01, 6F
→
04/11 10:02,
6年前
, 7F
04/11 10:02, 7F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章