[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [mosquitto-dev] does calling mosquitto_subscribe twice add a new subscription or replace the existing one?
|
Hi Steve,
If you call
mosquitto_subscribe(client, NULL, "topic1", 1);
mosquitto_subscribe(client, NULL, "topic2", 0);
then you should end up subscribed to both topic1 (with qos 1) and
topic2 (with qos0).
If you subsequently call
mosquitto_subscribe(client, NULL, "topic2", 1");
then your subscription for topic2 will be updated to be qos 1 instead.
It will not add an extra subscription for topic2.
I hope that clears things up.
Regards,
Roger
On 30 May 2017 at 03:39, Steve Prior <sprior@xxxxxxxxxxxx> wrote:
> I'm getting started using the mqtt pack for SWI-Prolog to subscribe to
> topics on a mosquitto message broker. The library under the covers uses the
> c mosquitto API.
>
> I've been able to subscribe to a topic and process incoming messages in
> Prolog - this is working. What I'm trying to understand is whether I can
> subscribe to two completely different topics using the same mqtt connection.
> I was under the impression that this was possible, but what I think I saw
> was than when I called subscribe a second time I started seeing the messages
> under the new topic, but no longer saw the messages I had previously
> subscribed to. Then when I called subscribe again with the original topic I
> saw only those and not the ones for the second topic.
>
> I've gone through the prolog -> mosquitto interface code and the interface
> code is doing very little beyond retrieving the connection and passing the
> call to the mosquitto c API, so I don't think that interface is adding any
> new restrictions.
>
> Looking at the c API documentation for mosquitto_subscribe it does not
> specify the behavior if it is called twice. Can anyone clarify if the new
> subscription topic is supposed to replace (or add) to any previous
> subscribed topics?
>
> Thanks
> Steve Prior
>
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev