當前位置: 首頁>>代碼示例>>Java>>正文


Java IMqttToken.waitForCompletion方法代碼示例

本文整理匯總了Java中org.eclipse.paho.client.mqttv3.IMqttToken.waitForCompletion方法的典型用法代碼示例。如果您正苦於以下問題:Java IMqttToken.waitForCompletion方法的具體用法?Java IMqttToken.waitForCompletion怎麽用?Java IMqttToken.waitForCompletion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.paho.client.mqttv3.IMqttToken的用法示例。


在下文中一共展示了IMqttToken.waitForCompletion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
private void connect(String serverURI, String clientId, String zkConnect) throws MqttException {
	
	mqtt = new MqttAsyncClient(serverURI, clientId);
	mqtt.setCallback(this);
	IMqttToken token = mqtt.connect();
	Properties props = new Properties();
	
	//Updated based on Kafka v0.8.1.1
	props.put("metadata.broker.list", "localhost:9092");
       props.put("serializer.class", "kafka.serializer.StringEncoder");
       props.put("partitioner.class", "example.producer.SimplePartitioner");
       props.put("request.required.acks", "1");
	
	ProducerConfig config = new ProducerConfig(props);
	kafkaProducer = new Producer<String, String>(config);
	token.waitForCompletion();
	logger.info("Connected to MQTT and Kafka");
}
 
開發者ID:DhruvKalaria,項目名稱:MQTTKafkaBridge,代碼行數:19,代碼來源:Bridge.java

示例2: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/DC/#", 1);
    client.subscribe("iot/tf/localhost/4223/DC/#", 1);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();

    client.publish("iot/tf/localhost/4223/DC/e1cw8v/intent/<" + UID + ">/driveMode/value", "0".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/DC/e1cw8v/intent/<" + UID + ">/enabled/value", "true".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/DC/e1cw8v/intent/<" + UID + ">/currentVelocityPeriod/period", "1".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/DC/e1cw8v/intent/<" + UID + ">/acceleration/value", "2000".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/DC/e1cw8v/intent/<" + UID + ">/velocity/value", "7000".getBytes(), 1, false);

} catch (Exception ex) {
    Logger.getLogger(DC.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:26,代碼來源:DC.java

示例3: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/IMU/#", 1);
    client.subscribe("iot/tf/localhost/4223/IMU/#", 1);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();

    client.publish("iot/tf/localhost/4223/IMU/6lyl0m/intent/<" + UID + ">/allData/period", "0".getBytes(), 1, false);
} catch (Exception ex) {
    Logger.getLogger(IMU.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:21,代碼來源:IMU.java

示例4: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/IMUV2/#", 1);
    client.subscribe("iot/tf/localhost/4223/IMUV2/#", 1);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();

    client.publish("iot/tf/localhost/4223/IMUV2/9xblji/intent/<" + UID + ">/linearAcceleration/period", "10".getBytes(), 1, false);
} catch (Exception ex) {
    Logger.getLogger(IMUV2.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:21,代碼來源:IMUV2.java

示例5: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/SoundIntensity/#", 0);
    client.subscribe("iot/tf/localhost/4223/SoundIntensity/#", 0);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();
    client.publish("iot/tf/localhost/4223/SoundIntensity/fnniyg/intent/<" + UID + ">/callbackThreshold/option", "g".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/SoundIntensity/fnniyg/intent/<" + UID + ">/callbackThreshold/min", "2".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/SoundIntensity/fnniyg/intent/<" + UID + ">/callbackThreshold/max", "2".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/SoundIntensity/fnniyg/intent/<" + UID + ">/callbackThreshold/enabled", "true".getBytes(), 1, false);
} catch (Exception ex) {
    Logger.getLogger(SoundIntensity.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:23,代碼來源:SoundIntensity.java

示例6: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/Barometer/#", 0);
    client.subscribe("iot/tf/localhost/4223/Barometer/#", 0);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();
    client.publish("iot/tf/localhost/4223/Barometer/dpm5s8/intent/<" + UID + ">/averaging/averagePressure", "0".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/Barometer/dpm5s8/intent/<" + UID + ">/averaging/movingAveragePressure", "0".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/Barometer/dpm5s8/intent/<" + UID + ">/averaging/averageTemperature", "0".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/Barometer/dpm5s8/intent/<" + UID + ">/averaging/enabled", "true".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/Barometer/dpm5s8/intent/<" + UID + ">/airPressureCallbackPeriod/period", "2".getBytes(), 1, false);
} catch (Exception ex) {
    Logger.getLogger(Barometer.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:24,代碼來源:Barometer.java

示例7: position

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
@Override
   public void position(short s, short s1) {
IMqttToken token = null;

try {
    getEvent(PositionValueEvent.class
    ).update(VALUE_X, s);
    while (token
	    == null) {
	token = getEvent(PositionValueEvent.class).update(VALUE_Y, s1);
    }

    token.waitForCompletion(
	    10);
} catch (Exception ex) {
    Logger.getLogger(Joystick.class
	    .getName()).log(Level.SEVERE, null, ex);
    System.out.println(token.getException());

}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:23,代碼來源:Joystick.java

示例8: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/LCD20x4/#", 1);
    client.subscribe("iot/tf/localhost/4223/LCD20x4/#", 1);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true);
    Thread.sleep(1000);

} catch (Exception ex) {
    Logger.getLogger(Button.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:21,代碼來源:Button.java

示例9: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/RotaryPoti/#", 0);
    client.subscribe("iot/tf/localhost/4223/RotaryPoti/#", 0);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();
    client.publish("iot/tf/localhost/4223/RotaryPoti/etahff/intent/<" + UID + ">/positionCallbackPeriod/period", "1".getBytes(), 1, false);

    client.publish("iot/tf/localhost/4223/DC/e1cw8v/intent/<" + UID + ">/driveMode/value", "0".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/DC/e1cw8v/intent/<" + UID + ">/enabled/value", "true".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/DC/e1cw8v/intent/<" + UID + ">/currentVelocityPeriod/period", "1".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/DC/e1cw8v/intent/<" + UID + ">/acceleration/value", "20000".getBytes(), 1, false);

} catch (Exception ex) {
    Logger.getLogger(RotaryPotiDC.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:26,代碼來源:RotaryPotiDC.java

示例10: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/RotaryPoti/#", 0);
    client.subscribe("iot/tf/localhost/4223/RotaryPoti/#", 0);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();
    client.publish("iot/tf/localhost/4223/RotaryPoti/etahff/intent/<" + UID + ">/positionCallbackPeriod/period", "1".getBytes(), 1, false);
} catch (Exception ex) {
    Logger.getLogger(RotaryPoti.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:20,代碼來源:RotaryPoti.java

示例11: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/DustDetector/#", 0);
    client.subscribe("iot/tf/localhost/4223/DustDetector/#", 0);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();

    client.publish("iot/tf/localhost/4223/DustDetector/dg4p7n/intent/<" + UID + ">/dustDensityCallbackPeriod/period", "1".getBytes(), 1, false);
} catch (Exception ex) {
    Logger.getLogger(DustDetector.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:21,代碼來源:DustDetector.java

示例12: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/LaserRangeFinder/#", 0);
    client.subscribe("iot/tf/localhost/4223/LaserRangeFinder/#", 0);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();
    client.publish("iot/tf/localhost/4223/LaserRangeFinder/eu1ew0/intent/<" + UID + ">/mode/mode", "1".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/LaserRangeFinder/eu1ew0/intent/<" + UID + ">/distanceCallbackPeriod/period", "1".getBytes(), 1, false);
    client.publish("iot/tf/localhost/4223/LaserRangeFinder/eu1ew0/intent/<" + UID + ">/velocityCallbackPeriod/period", "1".getBytes(), 1, false);

    client.publish("iot/tf/localhost/4223/LaserRangeFinder/eu1ew0/intent/<" + UID + ">/laser/enabled", "true".getBytes(), 1, false);

} catch (Exception ex) {
    Logger.getLogger(LaserRangeFinder.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:25,代碼來源:LaserRangeFinder.java

示例13: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/UVLight/#", 0);
    client.subscribe("iot/tf/localhost/4223/UVLight/#", 0);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();

    client.publish("iot/tf/localhost/4223/UVLight/eu463p/intent/<" + UID + ">/UVLightCallbackPeriod/period", "1".getBytes(), 1, false);
} catch (Exception ex) {
    Logger.getLogger(UVLight.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:21,代碼來源:UVLight.java

示例14: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/TemperatureIR/#", 0);
    client.subscribe("iot/tf/localhost/4223/TemperatureIR/#", 0);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();

    client.publish("iot/tf/localhost/4223/TemperatureIR/fdjob6/intent/<" + UID + ">/objectTemperatureCallbackPeriod/period", "1".getBytes(), 1, false);
} catch (Exception ex) {
    Logger.getLogger(TemperatureIR.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:21,代碼來源:TemperatureIR.java

示例15: connect

import org.eclipse.paho.client.mqttv3.IMqttToken; //導入方法依賴的package包/類
public void connect() throws MqttException {
MqttConnectOptions options = new MqttConnectOptions();
//options.setUserName("user");
//options.setPassword("pass".toCharArray());
options.setWill(UID + "/status", "connection broken".getBytes(), 1, true);
options.setCleanSession(true);
IMqttToken token = client.connect(options, null, new MQTTActionHandler());
token.waitForCompletion();
try {
    client.subscribe("iot/tf/description/CO2/#", 0);
    client.subscribe("iot/tf/localhost/4223/CO2/#", 0);
    client.subscribe("iot/tf/#", 1);
    client.publish("iot/tf/MQTT2TF/0/intent/<" + UID + ">/stackHandler/stackAddress", "{\"hostName\":\"localhost\",\"port\":4223}".getBytes(), 1, true).waitForCompletion();

    client.publish("iot/tf/localhost/4223/CO2/e0542c/intent/<" + UID + ">/CO2ConcentrationCallbackPeriod/period", "1".getBytes(), 1, false);
} catch (Exception ex) {
    Logger.getLogger(CO2.class.getName()).log(Level.SEVERE, null, ex);
}

   }
 
開發者ID:knr1,項目名稱:ch.bfh.mobicomp,代碼行數:21,代碼來源:CO2.java


注:本文中的org.eclipse.paho.client.mqttv3.IMqttToken.waitForCompletion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。