Skip to content

Commit

Permalink
Merge pull request #424 from novastone-media/SessionCompletion
Browse files Browse the repository at this point in the history
Session completion
  • Loading branch information
jcavar authored Feb 1, 2018
2 parents 0e21e56 + 634edd8 commit 9ff7c36
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 291 deletions.
2 changes: 1 addition & 1 deletion MQTTClient/MQTTClient/ForegroundReconnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (void)appDidEnterBackground {
}

- (void)appDidBecomeActive {
[self.sessionManager connectToLast];
[self.sessionManager connectToLast:nil];
}

- (void)endBackgroundTask {
Expand Down
134 changes: 4 additions & 130 deletions MQTTClient/MQTTClient/MQTTSessionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,36 +167,6 @@ typedef NS_ENUM(int, MQTTSessionManagerState) {
connectInForeground:(BOOL)connectInForeground
queue:(dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER;

/** initWithPersistence sets the MQTTPersistence properties other than default
* @param persistent YES or NO (default) to establish file or in memory persistence.
* @param maxWindowSize (a positive number, default is 16) to control the number of messages sent before waiting for acknowledgement in Qos 1 or 2. Additional messages are stored and transmitted later.
* @param maxSize (a positive number of bytes, default is 64 MB) to limit the size of the persistence file. Messages published after the limit is reached are dropped.
* @param maxMessages (a positive number, default is 1024) to limit the number of messages stored. Additional messages published are dropped.
* @param connectInForeground Whether or not to connect the MQTTSession when the app enters the foreground, and disconnect when it becomes inactive. When NO, the caller is responsible for calling -connectTo: and -disconnect. Defaults to YES.
* @param queue Queue for MQTTSession.
* @return the initialized MQTTSessionManager object
*/

- (MQTTSessionManager *)initWithPersistence:(BOOL)persistent
maxWindowSize:(NSUInteger)maxWindowSize
maxMessages:(NSUInteger)maxMessages
maxSize:(NSUInteger)maxSize
connectInForeground:(BOOL)connectInForeground
queue:(dispatch_queue_t)queue;

/** initWithPersistence sets the MQTTPersistence properties other than default
* @param persistent YES or NO (default) to establish file or in memory persistence.
* @param maxWindowSize (a positive number, default is 16) to control the number of messages sent before waiting for acknowledgement in Qos 1 or 2. Additional messages are stored and transmitted later.
* @param maxSize (a positive number of bytes, default is 64 MB) to limit the size of the persistence file. Messages published after the limit is reached are dropped.
* @param maxMessages (a positive number, default is 1024) to limit the number of messages stored. Additional messages published are dropped.
* @return the initialized MQTTSessionManager object
*/

- (MQTTSessionManager *)initWithPersistence:(BOOL)persistent
maxWindowSize:(NSUInteger)maxWindowSize
maxMessages:(NSUInteger)maxMessages
maxSize:(NSUInteger)maxSize;

/** Connects to the MQTT broker and stores the parameters for subsequent reconnects
* @param host specifies the hostname or ip address to connect to. Defaults to @"localhost".
* @param port specifies the port to connect to
Expand All @@ -215,6 +185,7 @@ typedef NS_ENUM(int, MQTTSessionManagerState) {
* @param securityPolicy A custom SSL security policy or nil.
* @param certificates An NSArray of the pinned certificates to use or nil.
* @param protocolLevel Protocol version of the connection.
* @param connectHandler Called when first connected or if error occurred. It is not called on subsequent internal reconnects.
*/

- (void)connectTo:(NSString *)host
Expand All @@ -233,109 +204,12 @@ typedef NS_ENUM(int, MQTTSessionManagerState) {
withClientId:(NSString *)clientId
securityPolicy:(MQTTSSLSecurityPolicy *)securityPolicy
certificates:(NSArray *)certificates
protocolLevel:(MQTTProtocolVersion)protocolLevel;

/** Connects to the MQTT broker and stores the parameters for subsequent reconnects
* @param host see connectTo description
* @param port see connectTo description
* @param tls see connectTo description
* @param keepalive see connectTo description
* @param clean see connectTo description
* @param auth see connectTo description
* @param user see connectTo description
* @param pass see connectTo description
* @param will see connectTo description
* @param willTopic see connectTo description
* @param willMsg see connectTo description
* @param willQos see connectTo description
* @param willRetainFlag see connectTo description
* @param clientId see connectTo description
* @param securityPolicy see connectTo description
* @param certificates An see connectTo description
*/

- (void)connectTo:(NSString *)host
port:(NSInteger)port
tls:(BOOL)tls
keepalive:(NSInteger)keepalive
clean:(BOOL)clean
auth:(BOOL)auth
user:(NSString *)user
pass:(NSString *)pass
will:(BOOL)will
willTopic:(NSString *)willTopic
willMsg:(NSData *)willMsg
willQos:(MQTTQosLevel)willQos
willRetainFlag:(BOOL)willRetainFlag
withClientId:(NSString *)clientId
securityPolicy:(MQTTSSLSecurityPolicy *)securityPolicy
certificates:(NSArray *)certificates;

/** Convenience alternative to full paramter connectTo
* @param host see connectTo description
* @param port see connectTo description
* @param tls see connectTo description
* @param keepalive see connectTo description
* @param clean see connectTo description
* @param auth see connectTo description
* @param user see connectTo description
* @param pass see connectTo description
* @param will see connectTo description
* @param willTopic see connectTo description
* @param willMsg see connectTo description
* @param willQos see connectTo description
* @param willRetainFlag see connectTo description
* @param clientId see connectTo description
*/

- (void)connectTo:(NSString *)host
port:(NSInteger)port
tls:(BOOL)tls
keepalive:(NSInteger)keepalive
clean:(BOOL)clean
auth:(BOOL)auth
user:(NSString *)user
pass:(NSString *)pass
will:(BOOL)will
willTopic:(NSString *)willTopic
willMsg:(NSData *)willMsg
willQos:(MQTTQosLevel)willQos
willRetainFlag:(BOOL)willRetainFlag
withClientId:(NSString *)clientId;

/** Convenience alternative to full paramter connectTo
* @param host see connectTo description
* @param port see connectTo description
* @param tls see connectTo description
* @param keepalive see connectTo description
* @param clean see connectTo description
* @param auth see connectTo description
* @param user see connectTo description
* @param pass see connectTo description
* @param willTopic the Will Topic is a string, must not be nil
* @param will the Will Message, might be zero length
* @param willQos see connectTo description
* @param willRetainFlag see connectTo description
* @param clientId see connectTo description
*/

- (void)connectTo:(NSString *)host
port:(NSInteger)port
tls:(BOOL)tls
keepalive:(NSInteger)keepalive
clean:(BOOL)clean
auth:(BOOL)auth
user:(NSString *)user
pass:(NSString *)pass
willTopic:(NSString *)willTopic
will:(NSData *)will
willQos:(MQTTQosLevel)willQos
willRetainFlag:(BOOL)willRetainFlag
withClientId:(NSString *)clientId;
protocolLevel:(MQTTProtocolVersion)protocolLevel
connectHandler:(MQTTConnectHandler)connectHandler;

/** Re-Connects to the MQTT broker using the parameters for given in the connectTo method
*/
- (void)connectToLast;
- (void)connectToLast:(MQTTConnectHandler)connectHandler;

/** publishes data on a given topic at a specified QoS level and retain flag
Expand Down
Loading

0 comments on commit 9ff7c36

Please sign in to comment.