Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IoT connection callback to pass Session Present information to client #1558

Open
GeekOnIce opened this issue May 17, 2019 · 1 comment
Open
Labels
feature-request Request a new feature iot Issues related to the IoT SDK product review Issues awaiting product evaluation/review

Comments

@GeekOnIce
Copy link

Which AWS Services is the feature request for?
IoT, specifically the AWSIoTDataManager class

Is your feature request related to a problem? Please describe.
The current API for connections takes a statusCallback closure that is called when the connection status changes, but there is no way for it to convey when a connection happens to a persistent session (as described in https://docs.aws.amazon.com/iot/latest/developerguide/mqtt-persistent-sessions.html). The persistent session does work, as the subscriptions are called if connecting within the expiry period, but there is currently no way for the client to know if it worked or not.

The current callback has an enumeration that indicates the connection status only. Looking at the code in the following function:

- (void)decoder:(AWSMQTTDecoder*)sender newMessage:(AWSMQTTMessage*)msg {
the CONNACK handler doesn't look at, store or pass on the first byte of the message data, which is the part of data indicating if the connection was to a persistent session or not.

Describe the solution you'd like
Add an optional callback parameter to the connection functions which would be called back specifically for "connected" events, passing the session present flag into the callback
e.g. current definition:

- (BOOL)connectUsingWebSocketWithClientId:(NSString *)clientId
                            cleanSession:(BOOL)cleanSession
                          statusCallback:(void (^)(AWSIoTMQTTStatus status))callback;

suggested definition:

- (BOOL)connectUsingWebSocketWithClientId:(NSString *)clientId
                            cleanSession:(BOOL)cleanSession
                          statusCallback:(void (^)(AWSIoTMQTTStatus status))callback
                       connectedCallback:(void (^)(BOOL *sessionPresent))connCallback;

When the status specifically goes from connecting -> connected, the framework would additionally call this new callback function and pass in the session present flag from the CONNACK it receives in the connection event.

Describe alternatives you've considered
One alternative would be to add an extendedCallback version of the function that would pass this flag into the status callback, but that doesn't seem useful since the sessionPresent parameter is only valid in the connection case.
Another alternative would be to add enum values, "connectedPresentSession" and "connectedCleanSession", but that would be a breaking change because either "connected" would be removed, or its meaning would change.

Additional context
N/A

@GeekOnIce GeekOnIce changed the title Add Session Present to IoT connection status callback Add IoT connection callback to pass Session Present information to client May 17, 2019
@rohandubal
Copy link
Contributor

Hello @GeekOnIce

Thank you for a detailed description explaining the use-case. I will take this as feature request to the team.

Thanks,
Rohan

@rohandubal rohandubal added feature-request Request a new feature iot Issues related to the IoT SDK product review Issues awaiting product evaluation/review labels May 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature iot Issues related to the IoT SDK product review Issues awaiting product evaluation/review
Projects
None yet
Development

No branches or pull requests

2 participants