mosquitto/test/lib/cpp/01-keepalive-pingreq.cpp

50 lines
719 B
C++
Raw Normal View History

#include <cassert>
2014-05-08 00:27:00 +02:00
#include <mosquittopp.h>
static int run = -1;
class mosquittopp_test : public mosqpp::mosquittopp
{
public:
mosquittopp_test(const char *id);
void on_connect(int rc);
};
mosquittopp_test::mosquittopp_test(const char *id) : mosqpp::mosquittopp(id)
{
}
void mosquittopp_test::on_connect(int rc)
{
if(rc){
exit(1);
}
}
int main(int argc, char *argv[])
{
struct mosquittopp_test *mosq;
assert(argc == 2);
int port = atoi(argv[1]);
2022-02-01 10:52:41 +01:00
int rc;
2014-05-08 00:27:00 +02:00
mosqpp::lib_init();
mosq = new mosquittopp_test("01-keepalive-pingreq");
mosq->connect("localhost", port, 5);
2014-05-08 00:27:00 +02:00
while(run == -1){
2022-02-01 10:52:41 +01:00
rc = mosq->loop();
if(rc) break;
2014-05-08 00:27:00 +02:00
}
2020-08-12 12:01:28 +02:00
delete mosq;
2014-05-08 00:27:00 +02:00
2020-05-05 12:56:10 +02:00
delete mosq;
2014-05-08 00:27:00 +02:00
mosqpp::lib_cleanup();
return run;
}