类 MqttUtil

java.lang.Object
cn.hamm.airpower.util.MqttUtil

@Configuration public class MqttUtil extends Object

MQTT助手类

作者:
Hamm.cn
  • 构造器详细资料

    • MqttUtil

      public MqttUtil()
  • 方法详细资料

    • createClient

      @NotNull public @NotNull org.eclipse.paho.client.mqttv3.MqttClient createClient() throws org.eclipse.paho.client.mqttv3.MqttException

      创建MQTT客户端

      返回:
      配置
      抛出:
      org.eclipse.paho.client.mqttv3.MqttException - 异常
    • createClient

      @NotNull public @NotNull org.eclipse.paho.client.mqttv3.MqttClient createClient(String id) throws org.eclipse.paho.client.mqttv3.MqttException

      创建MQTT客户端

      参数:
      id - 客户端ID
      返回:
      配置
      抛出:
      org.eclipse.paho.client.mqttv3.MqttException - 异常
    • createOption

      public org.eclipse.paho.client.mqttv3.MqttConnectOptions createOption()

      创建配置

      返回:
      配置
    • publish

      public void publish(@NotNull @NotNull String topic, @NotNull @NotNull String message) throws org.eclipse.paho.client.mqttv3.MqttException

      发送消息

      参数:
      topic - 主题
      message - 消息内容
      抛出:
      org.eclipse.paho.client.mqttv3.MqttException