功能邏輯是點(diǎn)擊預(yù)約按鈕延時(shí)通知客戶端
為什么總是時(shí)而好使時(shí)而不好使呢,哪位大神可以幫我看看么
訂閱
public function onWorkerStart(Worker $worker)
{
$redis = new \Workerman\Redis\Client('redis://127.0.0.1:6379');
$redis->auth('123456');
$redis->subscribe('resty',function ($channel, $message){
echo ' [x] ' . $channel.'|'.$message, "\n";
});
}
發(fā)布
public function publish()
{
$redis = new \Workerman\Redis\Client('redis://127.0.0.1:6379');
$redis->auth('123456');
$redis->publish('resty','Welcome Tinywan publish '.date('Y-m-d H:i:s'));
}
訂閱截圖
//用戶發(fā)過(guò)來(lái)消息5分鐘后執(zhí)行預(yù)約通知
$client = new Client('redis://127.0.0.1:6379');
$client->send('chat',json_encode($chat_arr),300);
估計(jì)是業(yè)務(wù)邏輯問(wèn)題。延遲消費(fèi)要用隊(duì)列,用這個(gè) http://m.wtbis.cn/doc/workerman/components/workerman-redis-queue.html
先直接用手冊(cè)里的測(cè)試?yán)訙y(cè)試,不加業(yè)務(wù)邏輯。測(cè)試沒(méi)問(wèn)題然后再一點(diǎn)一點(diǎn)加你的業(yè)務(wù)邏輯,這樣好定位。