Package org.openhab.io.transport.mqtt.internal

Examples of org.openhab.io.transport.mqtt.internal.MqttBrokerConnection


        continue;
      } else {
        logger.trace("Processing property: {} = {}", key, value);
      }

      MqttBrokerConnection conn = brokerConnections.get(name);
      if (conn == null) {
        conn = new MqttBrokerConnection(name);
        brokerConnections.put(name, conn);
      }

      if (property.equals("url")) {
        conn.setUrl(value);
      } else if (property.equals("user")) {
        conn.setUser(value);
      } else if (property.equals("pwd")) {
        conn.setPassword(value);
      } else if (property.equals("qos")) {
        conn.setQos(Integer.parseInt(value));
      } else if (property.equals("retain")) {
        conn.setRetain(Boolean.parseBoolean(value));
      } else if (property.equals("async")) {
        conn.setAsync(Boolean.parseBoolean(value));
      } else if (property.equals("clientId")) {
        conn.setClientId(value);
      } else if (property.equals("lwt")) {
        MqttWillAndTestament will = MqttWillAndTestament.fromString(value);
        logger.debug("Setting last will: {}", will);
        conn.setLastWill(will);
      } else if (property.equals("keepAlive")) {
        conn.setKeepAliveInterval(Integer.parseInt(value));
      } else {
        logger.warn("Unrecognized property: {}", key);
      }
    }
    logger.info("MQTT Service initialization completed.");
View Full Code Here


  public void deactivate() {
    logger.debug("Stopping MQTT Service...");

    Enumeration<String> e = brokerConnections.keys();
    while (e.hasMoreElements()) {
      MqttBrokerConnection conn = brokerConnections.get(e.nextElement());
      logger.info("Stopping broker connection '{}'", conn.getName());
      conn.close();
    }

    logger.debug("MQTT Service stopped.");
  }
View Full Code Here

   *            to look for.
   * @return existing connection or new one if it didn't exist yet.
   */
  private synchronized MqttBrokerConnection getConnection(String brokerName) {

    MqttBrokerConnection conn = brokerConnections.get(brokerName
        .toLowerCase());
    if (conn == null) {
      conn = new MqttBrokerConnection(brokerName);
      brokerConnections.put(brokerName.toLowerCase(), conn);
    }
    return conn;
  }
View Full Code Here

TOP

Related Classes of org.openhab.io.transport.mqtt.internal.MqttBrokerConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.