ably / ably-asset-tracking-swift

iOS client SDKs for the Ably Asset Tracking service.
Apache License 2.0
9 stars 6 forks source link

Subscriber Worker Queue: Subscribe To Presence #588

Open AndyTWF opened 1 year ago

AndyTWF commented 1 year ago

Implement the following workers on the Subscriber:

Disconnect

Disconnect is passed a callback function () -> Void (for details of this function, see later). It asynchronously calls ably.disconnect() for the trackable and then calls said function/

SubscribeForPresenceMessages

SubscribeForPresenceMessages is called as part of the connection establishment process, and is thus provided with a user callback that is used to feed the result back to the user. All of its work is in the doAsyncWork block.

It begins by getting the current/initial presence messages from ably channel, if this fails then Disconnect work is posted with a custom callback function. This function simply calls the user-provided function with the Result (ie the failure reasons) returned by subscribing for presence messages.

It then calls ably.subscribeForPresence(). If this fails, then a custom callback function similar to the one above is passed to posted Disconnect work. The listener for subscribing to presence should be to post UpdatePublisherPresence work with the presence data.

If all is successful ProcessInitialPresenceMessages work is posted with the initial presence messages.

An unexpected async error shall post Disconnect work.

ProcessInitialPresenceMessages

Calls a method on SubscriberProperties with the initial presence messages. These are iterated through and processed very similarly to how performPresenceUpdated currently does it.

It then posts SubscribeToChannel work, passing through the user callback function.

This work is dependent on:

sync-by-unito[bot] commented 1 year ago

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3406