本文整理匯總了Java中org.eclipse.paho.client.mqttv3.MqttConnectOptions.getWillMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java MqttConnectOptions.getWillMessage方法的具體用法?Java MqttConnectOptions.getWillMessage怎麽用?Java MqttConnectOptions.getWillMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.paho.client.mqttv3.MqttConnectOptions
的用法示例。
在下文中一共展示了MqttConnectOptions.getWillMessage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getValues
import org.eclipse.paho.client.mqttv3.MqttConnectOptions; //導入方法依賴的package包/類
private ContentValues getValues(Connection connection){
MqttConnectOptions conOpts = connection.getConnectionOptions();
MqttMessage lastWill = conOpts.getWillMessage();
ContentValues values = new ContentValues();
//put the column values object
values.put(COLUMN_CLIENT_HANDLE, connection.handle());
values.put(COLUMN_HOST, connection.getHostName());
values.put(COLUMN_port, connection.getPort());
values.put(COLUMN_client_ID, connection.getId());
values.put(COLUMN_ssl, connection.isSSL());
values.put(COLUMN_KEEP_ALIVE, conOpts.getKeepAliveInterval());
values.put(COLUMN_TIME_OUT, conOpts.getConnectionTimeout());
values.put(COLUMN_USER_NAME, conOpts.getUserName());
values.put(COLUMN_TOPIC, conOpts.getWillDestination());
//uses "condition ? trueValue: falseValue" for in line converting of values
char[] password = conOpts.getPassword();
values.put(COLUMN_CLEAN_SESSION, conOpts.isCleanSession() ? 1 : 0); //convert boolean to int and then put in values
values.put(COLUMN_PASSWORD, password != null ? String.valueOf(password) : null); //convert char[] to String
values.put(COLUMN_MESSAGE, lastWill != null ? new String(lastWill.getPayload()) : null); // convert byte[] to string
values.put(COLUMN_QOS, lastWill != null ? lastWill.getQos() : 0);
if (lastWill == null) {
values.put(COLUMN_RETAINED, 0);
}
else {
values.put(COLUMN_RETAINED, lastWill.isRetained() ? 1 : 0); //convert from boolean to int
}
return values;
}