You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

27 lines
554 B

<?php
declare(strict_types=1);
namespace App\TaskWorker;
use App\Libs\MQTTClient;
use Hyperf\Task\Annotation\Task;
class MQTTClientTask
{
protected $mqttClient = null;
/**
* @Task
*/
public function getClient()
{
$this->mqttClient = new MQTTClient(env('MQTT_HOST'), env('MQTT_PORT'));
$this->mqttClient->setAuthentication(env('MQTT_NAME'), env('MQTT_PASS'));
if (env('MQTT_CERT')) {
$this->mqttClient->setEncryption(env('MQTT_CERT'));
}
return $this->mqttClient;
}
}