本文整理汇总了Java中org.eclipse.paho.client.mqttv3.internal.MemoryPersistence类的典型用法代码示例。如果您正苦于以下问题:Java MemoryPersistence类的具体用法?Java MemoryPersistence怎么用?Java MemoryPersistence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemoryPersistence类属于org.eclipse.paho.client.mqttv3.internal包,在下文中一共展示了MemoryPersistence类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.paho.client.mqttv3.internal.MemoryPersistence; //导入依赖的package包/类
public void start() {
log.info("Starting Wilcard subscriber");
try {
final String clientId = MqttClient.generateClientId();
final MqttClient mqttClient = new MqttClient(BROKER_URL, clientId, new MemoryPersistence());
mqttClient.setCallback(new SubscribeCallback(mqttClient));
log.info("Connecting to {} with clientID {}", BROKER_URL, clientId);
mqttClient.connect();
//We subscribe to wildcard
log.info("Subscribing to {}", TOPIC_SUBSCRIPTION);
mqttClient.subscribe(TOPIC_SUBSCRIPTION, QUALITY_OF_SERVICE_LEVEL);
} catch (MqttException e) {
log.error("An unexpected error occured. Exiting", e);
System.exit(1);
}
}
开发者ID:dc-square,项目名称:paho-wildcard-subscriber,代码行数:21,代码来源:WildcardSubscriber.java
示例2: MQTTSubscriber
import org.eclipse.paho.client.mqttv3.internal.MemoryPersistence; //导入依赖的package包/类
public MQTTSubscriber(PubSubMiddleware pubsub) {
try {
client = new MqttClient(BROKER_URL, MqttClient.generateClientId(),
new MemoryPersistence());
client.setCallback(new PushCallback(pubsub));
client.connect();
} catch (MqttException e) {
e.printStackTrace();
}
}
开发者ID:chauhansaurabhb,项目名称:EndUserInteractioion_RequestResponse_Command,代码行数:13,代码来源:MQTTSubscriber.java
示例3: MQTTPublisher
import org.eclipse.paho.client.mqttv3.internal.MemoryPersistence; //导入依赖的package包/类
public MQTTPublisher() {
try {
client = new MqttClient(BROKER_URL, MqttClient.generateClientId(),
new MemoryPersistence());
client.connect();
} catch (MqttException e) {
e.printStackTrace();
}
}
开发者ID:chauhansaurabhb,项目名称:EndUserInteractioion_RequestResponse_Command,代码行数:11,代码来源:MQTTPublisher.java
示例4: onCreate
import org.eclipse.paho.client.mqttv3.internal.MemoryPersistence; //导入依赖的package包/类
/**
* Initalizes the DeviceId and most instance variables
* Including the Connection Handler, Datastore, Alarm Manager
* and ConnectivityManager.
*/
@Override
public void onCreate() {
super.onCreate();
mDeviceId = String.format(DEVICE_ID_FORMAT,
Secure.getString(getContentResolver(), Secure.ANDROID_ID));
HandlerThread thread = new HandlerThread(MQTT_THREAD_NAME);
thread.start();
mConnHandler = new Handler(thread.getLooper());
try {
mDataStore = new MqttDefaultFilePersistence(getCacheDir().getAbsolutePath());
} catch(MqttPersistenceException e) {
e.printStackTrace();
mDataStore = null;
mMemStore = new MemoryPersistence();
}
mOpts = new MqttConnectOptions();
mOpts.setCleanSession(MQTT_CLEAN_SESSION);
// Do not set keep alive interval on mOpts we keep track of it with alarm's
mAlarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
mConnectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
}
开发者ID:JesseFarebro,项目名称:android-mqtt,代码行数:33,代码来源:MqttService.java
注:本文中的org.eclipse.paho.client.mqttv3.internal.MemoryPersistence类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论