mosquitto/test/lib/cpp/04-retain-qos0.cpp

49 lines
755 B
C++
Raw Normal View History

2014-05-07 22:27:00 +00:00
#include <cstring>
#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);
}else{
publish(NULL, "retain/qos0/test", strlen("retained message"), "retained message", 0, true);
}
}
int main(int argc, char *argv[])
{
struct mosquittopp_test *mosq;
int port = atoi(argv[1]);
2014-05-07 22:27:00 +00:00
mosqpp::lib_init();
mosq = new mosquittopp_test("retain-qos0-test");
mosq->connect("localhost", port, 60);
2014-05-07 22:27:00 +00:00
while(run == -1){
mosq->loop();
}
2020-05-05 10:56:10 +00:00
delete mosq;
2014-05-07 22:27:00 +00:00
mosqpp::lib_cleanup();
return run;
}