From 07341cdd410dc2a9142adadea54fd01da27b6902 Mon Sep 17 00:00:00 2001 From: Josip Cavar Date: Wed, 25 Apr 2018 10:10:12 +0200 Subject: [PATCH] Update readme --- README.md | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5732a690..061ae7c1 100644 --- a/README.md +++ b/README.md @@ -48,35 +48,29 @@ session.transport = transport; Subscribe to a topic: ```objective-c -[session subscribeToTopic:@"example/#" atLevel:2 subscribeHandler:^(NSError *error, NSArray *gQoss){ +[session subscribeToTopic:@"example/#" atLevel:MQTTQosLevelExactlyOnce subscribeHandler:^(NSError *error, NSArray *gQoss) { if (error) { NSLog(@"Subscription failed %@", error.localizedDescription); } else { NSLog(@"Subscription sucessfull! Granted Qos: %@", gQoss); } - }]; // this is part of the block API + }]; ``` -Add the following to receive messages for the subscribed topics +In your `MQTTSession` delegate, add the following to receive messages for the subscribed topics: + ```objective-c - - (void)newMessage:(MQTTSession *)session - data:(NSData *)data - onTopic:(NSString *)topic - qos:(MQTTQosLevel)qos - retained:(BOOL)retained - mid:(unsigned int)mid { - // this is one of the delegate callbacks +- (void)newMessage:(MQTTSession *)session data:(NSData *)data onTopic:(NSString *)topic qos:(MQTTQosLevel)qos retained:(BOOL)retained mid:(unsigned int)mid { + // New message received in topic } ``` Publish a message to a topic: ```objective-c -[session publishAndWaitData:data - onTopic:@"topic" - retain:NO - qos:MQTTQosLevelAtLeastOnce]; // this is part of the asynchronous API +[session publishData:someData onTopic:@"example/#" retain:NO qos:MQTTQosLevelAtMostOnce publishHandler:^(NSError *error) { +}]; ``` ## Installation