多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
消息发布端 // test为发布的频道名称,hello,world为发布的消息 $res = $redis->publish('test','hello,world'); 消息订阅端 (1)$redis->subscribe(array('test'), 'callback'); // 回调函数,这里写处理逻辑 function callback($instance, $channelName, $message) { echo $channelName, "==>", $message,PHP_EOL; } (2)$redis->subscribe(array($channelName, $channelName2), function ($redis, $chan, $msg){ echo "channel:".$chan.",message:".$msg."\n"; }); (3)$redis->psubscribe(['phone:switch'], [$this, 'sendTask']); public function sendTask($ins, $pattern, $channel, $data){ $this->ws->task($data); }