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

It would be nice if subscribe allowed to define own onMessageArrived handler for subscribed topic.

Open pitus opened this issue 6 years ago • 1 comments

I'm building a web client to node-red where I'm running mosca MQTT broker.

I'd like to be able to subscribe in the UI client to various topics and process subscribed messages locally within each UI module rather than worry about dispatching them from a shared mqtt.onMessageArrived handler. Perhaps adding an onMessageArrived option to the subscribe call would make sense for this? Internally, Paho.MQTT would route incoming messages to that handler if the topic matches subscription filter.

Or, subscribe could return a mediator object that would have its own onMessageArrived handler as well as publish method, which would automatically set the topic based on the subscription? However, this may be an overkill and a problem if subscription uses wildcards.

pitus avatar Feb 17 '19 02:02 pitus

Just started looking into a similar problem. Routing messages of varying payloads to UI components that are interested in them is not a trivial task given the current architecture.

melgish avatar Aug 24 '19 22:08 melgish