本文整理汇总了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;
}