paho.mqtt.javascript icon indicating copy to clipboard operation
paho.mqtt.javascript copied to clipboard

subscribe only takes a single topic, yet returns an array

Open jpwsutton opened this issue 9 years ago • 0 comments

migrated from Bugzilla #440767 status UNCONFIRMED severity normal in component MQTT-JS for 1.1 Reported in version 1.0 on platform All Assigned to: Tang Zi Han

On 2014-07-30 08:57:30 -0400, Karl Palsson wrote:

MQTT Spec allows sending multiple topics to subscribe in a single message, and replies with a list of granted QoS.

The current API only allows subscribing to a single topic, yet still returns an array, (with only one entry)

Ideally, both of these would work:

client.subscribe(topicA, qosA, {existing options blob (if we must) for callback definition}) which would invoke callbacks with just a single granted qos field, not an array,

and also...

client.subscribe([[topicA, qosA],[topicB,qosB],....], ...) which would return an array of qos's.

I don't actually personally even need a way to subscribe to multiple topics in one call, but the only time I would ever want an array of granted qos back is if I had actually subscribed to multiple topics.

On 2014-08-26 01:49:43 -0400, Tang Zi Han wrote:

Currently the subscribe API allows a single topic and return an array of grantedQos. The first fix step is to return a single grantedQos to match one topic.

On 2014-09-08 05:57:23 -0400, Al Stockdill-Mander wrote:

Changing the return type in the callback is an API change, so not something I would be keen to see. Perhaps it would be better to allow subscriptions to multiple topics in a subscribe call.

On 2014-09-08 06:09:11 -0400, Karl Palsson wrote:

If the API is confusing and inconsistent, surely there must be a path to change it. Backwards compatible is only useful if the old way is good.

On 2015-01-08 02:10:31 -0500, Tang Zi Han wrote:

(In reply to Tang Zi Han from comment # 1)

Currently the subscribe API allows a single topic and return an array of grantedQos. The first fix step is to return a single grantedQos to match one topic. Commit change to develop branch: https://git.eclipse.org/r/#/c/39165/

Currently the subscribe api : this.subscribe = function (filter, subscribeOptions) the qos is a number and include in subscribeOptions. It is not very clear to change the api to subscribe ([topic1,topic2],{qos:[1,1],onsuccess:function(){},onfailure:function(){}....})

In current version, it will be a big api change if changing the api to client.subscribe([[topicA, qosA],[topicB,qosB],....], callback).

It's better to add a new api to subscribe multiple topic in the following version.

jpwsutton avatar Feb 04 '16 14:02 jpwsutton