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


Java IMqttDeliveryToken.getTopics方法代碼示例

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


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

示例1: deliveryComplete

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; //導入方法依賴的package包/類
/**
 * Callback method which gets triggered upon successful completion of a message delivery to
 * the broker.
 *
 * @param iMqttDeliveryToken the MQTT-DeliveryToken which includes the details about the
 *                           specific message delivery.
 */
@Override
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
	String message = "";
	try {
		message = iMqttDeliveryToken.getMessage().toString();
	} catch (MqttException e) {
		log.error(
				"Error occurred whilst trying to read the message from the MQTT delivery " +
						"token.");
	}
	String topic = iMqttDeliveryToken.getTopics()[0];
	String client = iMqttDeliveryToken.getClient().getClientId();

	if (log.isDebugEnabled()) {
		log.debug("Message - '" + message + "' of client [" + client + "] for the topic (" +
				          topic +
				          ") was delivered successfully.");
	}
}
 
開發者ID:wso2-incubator,項目名稱:iot-server-appliances,代碼行數:27,代碼來源:MQTTCommunicationHandler.java

示例2: deliveryComplete

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; //導入方法依賴的package包/類
/**
 * Callback method which gets triggered upon successful completion of a message delivery to
 * the broker.
 *
 * @param iMqttDeliveryToken the MQTT-DeliveryToken which includes the details about the
 *                           specific message delivery.
 */
@Override
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
    String message = "";
    try {
        message = iMqttDeliveryToken.getMessage().toString();
    } catch (MqttException e) {
        //TODO:: Throw errors
        log.error(
                "Error occurred whilst trying to read the message from the MQTT delivery " +
                        "token.");
    }
    String topic = iMqttDeliveryToken.getTopics()[0];
    String client = iMqttDeliveryToken.getClient().getClientId();

    if (log.isDebugEnabled()) {
        log.debug("Message - '" + message + "' of client [" + client + "] for the topic (" +
                          topic + ") was delivered successfully.");
    }
}
 
開發者ID:wso2-incubator,項目名稱:iot-server-agents,代碼行數:27,代碼來源:MQTTTransportHandler.java

示例3: deliveryComplete

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; //導入方法依賴的package包/類
/**
 * Callback method which gets triggered upon successful completion of a message delivery to
 * the broker.
 *
 * @param iMqttDeliveryToken the MQTT-DeliveryToken which includes the details about the
 *                           specific message delivery.
 */
@Override
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
	String message = "";
	try {
		message = iMqttDeliveryToken.getMessage().toString();
	} catch (MqttException e) {
		log.error(
				"Error occurred whilst trying to read the message from the MQTT delivery " +
						"token.");
	}
	String topic = iMqttDeliveryToken.getTopics()[0];
	String client = iMqttDeliveryToken.getClient().getClientId();

	if (log.isDebugEnabled()) {
		log.debug("Message - '" + message + "' of client [" + client + "] for the topic (" +
				          topic + ") was delivered successfully.");
	}
}
 
開發者ID:wso2-incubator,項目名稱:iot-server-agents,代碼行數:26,代碼來源:MQTTCommunicationHandler.java

示例4: deliveryComplete

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; //導入方法依賴的package包/類
/**
 * Callback method which gets triggered upon successful completion of a message delivery to the broker.
 *
 * @param iMqttDeliveryToken the MQTT-DeliveryToken which includes the details about the specific message delivery.
 */
@Override
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
    String topic = iMqttDeliveryToken.getTopics()[0];
    String client = iMqttDeliveryToken.getClient().getClientId();

    try {
        if (iMqttDeliveryToken.isComplete()) {
            if (iMqttDeliveryToken.getMessage() != null) {
                String message = iMqttDeliveryToken.getMessage().toString();
                Log.d(TAG, "Message to client [" + client + "] under topic (" + topic +
                        ") was delivered successfully with the delivery message: '" + message + "'");
            } else {
                Log.d(TAG, "Message to client [" + client + "] under topic (" + topic +
                        ") was delivered successfully.");
            }
        } else {
            Log.w(TAG, "FAILED: Delivery of MQTT message to [" + client + "] under topic [" + topic + "] failed.");
        }
    } catch (MqttException e) {
        Log.w(TAG, "Error occurred whilst trying to read the message from the MQTT delivery token.");
    }
}
 
開發者ID:wso2-incubator,項目名稱:iot-server-agents,代碼行數:28,代碼來源:MQTTTransportHandler.java

示例5: deliveryComplete

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; //導入方法依賴的package包/類
/**
 * Inform when message delivery is complete for a published message.
 *
 * @param iMqttDeliveryToken The message complete token
 */
@Override
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
    for (String topic : iMqttDeliveryToken.getTopics()) {
        log.info("Message delivered successfully to topic : \"" + topic + "\".");
    }
}
 
開發者ID:wso2,項目名稱:product-ei,代碼行數:12,代碼來源:SimpleMQTTCallback.java


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