MQTT For Yii2 Base On Swoole 4

MQTT server for Yii2 base on swoole 4, Resolve topic as a route reflect into controller/action/param, And support redis pub/sub to trigger async task from your web application.

yii2-swoole-mqtt

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

1 Like