You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
582 B
C
34 lines
582 B
C
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <mosquitto.h>
|
|
|
|
#define QOS 2
|
|
|
|
int cb(struct mosquitto *mosq, void *userdata, const struct mosquitto_message *msg)
|
|
{
|
|
assert(msg);
|
|
assert(!strcmp(msg->topic, "qos2/test"));
|
|
return 1;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int port;
|
|
|
|
if(argc < 2){
|
|
return 1;
|
|
}
|
|
port = atoi(argv[1]);
|
|
|
|
mosquitto_lib_init();
|
|
|
|
mosquitto_subscribe_callback(
|
|
cb, NULL, "qos2/test", QOS, "localhost", port,
|
|
"subscribe-qos2-test", 60, true, NULL, NULL, NULL, NULL);
|
|
|
|
mosquitto_lib_cleanup();
|
|
return 0;
|
|
}
|