MQTT For Yii2 Base On Swoole 4 [ 2.0 版本 ]
基于Swoole 4的Yii2 MQTT扩展, 将遵循pathInfo的Topic解析到到controller/action/param, 类Yii2原生路由机制, 还是熟悉的配方, 还是原来味道! 同时支持Redis Pub/Sub 从Web应用递交异步任务.
easy to use:
``
//MQTT subscribe topic: "channel/count/100001" will handle at:
class ChannelController{
public function actionCount($channel_id){
echo "client {$this->fd} subscribed the count change of channel {$channel_id}";
}
}
//client 1 subscribed the count change of channel 100001
OR
//MQTT Publish Topic: "channel/join/100001" with payload: "Foo" will handle at:
class ChannelController{
public function actionJoin($channel_id, $who){
echo "{$who} join in channel {$channel_id}";
}
}
// Foo join in channel 100001
``
原文链接: https://forum.yiiframework.com/t/mqtt-for-yii2-base-on-swoole-4/123369
immusen 北京
注册时间:2015-09-24
最后登录:2024-04-17
在线时长:16小时32分
最后登录:2024-04-17
在线时长:16小时32分
- 粉丝6
- 金钱520
- 威望40
- 积分1080
共 0 条评论