Skip to content

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

@jin-null

Description

@jin-null

`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();

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions