mqtt icon indicating copy to clipboard operation
mqtt copied to clipboard

it works fine in examples but can not subscribe the 'test' topic in laravel command

Open jin-null opened this issue 4 years ago • 0 comments

`public function handle() { global $argv; $action = $this->argument('action'); if (!in_array($action, ['start', 'stop'])) { $this->error('Error Arguments'); exit; } $argv[0] = 'workerman:httpserver'; $argv[1] = $action; $argv[2] = $this->option('daemonize') ? '-d' : ''; $worker = new Worker(); $worker->onWorkerStart = function () { // $mqtt = new Client('mqtt://192.168.0.247:1883'); $mqtt = new \Workerman\Mqtt\Client('mqtt://192.168.0.247:1883'); Log::info(1); $mqtt->onConnect = function ($mqtt) { $mqtt->subscribe('test'); $this->info(2); }; $mqtt->onMessage = function ($topic, $content) { var_dump($topic, $content); $this->info($content); }; }; Worker::runAll();

}`

jin-null avatar Jun 02 '20 10:06 jin-null