IOS使用mosquitto如何设置持久化?

如下代码是初始化 mosquitto,网上查了只要设置cleansession为false就表示是持久化订阅了,但是测试下来并没有实现持久化的功能。求大神帮忙哈,小弟万分感谢!!!


- (MosquittoClient*) initWithClientId: (NSString*) clientId {
if ((self = [super init])) {
const char* cstrClientId = [clientId cStringUsingEncoding:NSUTF8StringEncoding];
[self setHost: nil];
[self setPort: 1883];
[self setKeepAlive: 60];
[self setCleanSession: YES]; //NOTE: this isdisable clean to keep the broker remember this client

mosq = mosquitto_new(cstrClientId, cleanSession, self);
mosquitto_connect_callback_set(mosq, on_connect);
mosquitto_disconnect_callback_set(mosq, on_disconnect);
mosquitto_publish_callback_set(mosq, on_publish);
mosquitto_message_callback_set(mosq, on_message);
mosquitto_subscribe_callback_set(mosq, on_subscribe);
mosquitto_unsubscribe_callback_set(mosq, on_unsubscribe);
timer = nil;
}
return self;
}

你可能感兴趣的:(xcode,object-c)