Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] CPP - Async Client's Connect Method gives "pure virtual method called" error. Anyone knows the error?

Hello,

Check if SCallback is not destroying the aclient in the
SCallback cb(this->aclient, opts, topic_name);?

Is there any compiler warning regarding the lack of virtual method
implementation?

And why the method A::connect(mqtt:connect_options opts, SCallback cb)
receives SCallback by value, not by reference or move semantics?

Regards,

2018-02-01 13:21 GMT+01:00 Bartu Doruk Demirkıran <demirkiran.bartud@xxxxxxxxx>:
> Hi all,
>
> I am developing an application for developers in order to increase the
> efficient work. To do so, I created new methods for the codes in heavily
> use. Whenever I try to put the async client as attribute and a connect
> method in a different method, I get the following-up error:
>
> pure virtual method called
> terminate called without an active exception
> Aborted (core dumped)
>
> To give insights and make the understanding clear, a few snippet from my
> code as follow:
>
> void A::connect(mqtt:connect_options opts, SCallback cb) {
>         try {
>             this->aclient.connect(opts, nullptr, cb);
>         } catch (const mqtt::exception&) {
>             throw std::runtime_error("Couldn't connect");
>         }
> }
>
>
> Above methos to connect and I have setup:
>
> void A::setup() {
>         mqtt::connect_options opts;
>         opts.set_keep_alive_interval(20);
>         opts.set_clean_session(true);
>         SCallback cb(this->aclient, opts, topic_name);
>         this->aclient.set_callback(cb);
>         this->connect(opts, cb); // throws the error.
> }
>
> Afterwards, the developer will do the job and close the connection. To
> illustrate:
>
> void A::newJob() {
>      this->setup();
>      // here comes the work
>      this->close();
> }
>
> Has anyone experienced it?
> Thanks in advance
>
>
> _______________________________________________
> paho-dev mailing list
> paho-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/paho-dev



-- 
Guilherme Maciel Ferreira
Site: http://guilhermemacielferreira.com/
Skype: guilherme.maciel.ferreira


Back to the top