Flutter_MQTT icon indicating copy to clipboard operation
Flutter_MQTT copied to clipboard

If multiple subscriptions are required, updates. Listen should be set in mqttManager or separately on each page

Open jahnli opened this issue 3 years ago • 7 comments

If multiple subscriptions are required, updates. Listen should be set in mqttManager or separately on each page

jahnli avatar Sep 07 '21 07:09 jahnli

@jahnli Check here https://github.com/anoop4real/Flutter_mqtt_new this uses a shared manager.

anoop4real avatar Sep 07 '21 08:09 anoop4real

The current situation is that I subscribed to one topic on page A and wrote an MqttClientTopicFilter updates. Listen. When I destroyed page A, I cancelled the subscription and re-subscribed to the topic when I entered page A again ,This resulted in repeated messages being returned multiple times in update.listen

jahnli avatar Sep 07 '21 08:09 jahnli

If multiple pages have multiple topics, updates. Listen needs to be written several times

jahnli avatar Sep 07 '21 08:09 jahnli

@jahnli Please check here https://github.com/anoop4real/Flutter_mqtt_new this issue is fixed https://github.com/anoop4real/Flutter_mqtt_new/issues/1

Also if you have multiple topics subscribed, just filter those by topic from payload, hope it helps

anoop4real avatar Sep 07 '21 08:09 anoop4real

I met the same problem, but I didn't find the specific code to solve this problem. Could you please intercept or tell me which one it is

jahnli avatar Sep 07 '21 08:09 jahnli

@jahnli Mostly it was because the usecase in this project was basic, the main issue was that I was not handling the subcribe call properly. The idea is make sure the mqttClient listen only once and subscription can happen multiple times

anoop4real avatar Sep 07 '21 20:09 anoop4real

Ok, thanks for your advice

jahnli avatar Sep 08 '21 01:09 jahnli