Comment 4 for bug 1261683

Revision history for this message
Roger Light (roger.light) wrote : Re: [Bug 1261683] Re: Blocking mode is not really supported

Something like this should work, assuming you really are waiting for
the publish to complete before sending another publish of course.

void on_publish(struct mosquitto *mosq, void *userdata, int mid)
{
    int *r = userdata;

    if(r){
        *r = 0;
    }
}

...
mosquitto_userdata_set(mosq, &run);
...

run = 1;
mosquitto_publish(mosq, ...);

while(run){
    rc = mosquitto_loop(mosq, -1, 1);
    if(rc != MOSQ_ERR_SUCCESS){
        /* Handle error */
    }
}

On Wed, Dec 18, 2013 at 6:40 AM, Yun Wu <wuyun1984_1984@163.com> wrote:
> Thanks.
>
> mosquitto_lib_init() is already called in my codes.
>
> In fact I just want reliable APIs for publish/subscribe/..., which means
> when they return SUCCESS, everything is indeed successfully finished.
>
> Do you have any idea of implementing them based on libmosuiqtto APIs?
>
> --
> You received this bug notification because you are subscribed to
> mosquitto.
> https://bugs.launchpad.net/bugs/1261683
>
> Title:
> Blocking mode is not really supported
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mosquitto/+bug/1261683/+subscriptions