Returns the message topic.

C Language

const char* mqtt_get_topic( MQTT_MESSAGE message);

Example MQTT Vuser Functions


Name Comments
message A message handle returned by mqtt_read_inbox.


mqtt_get_topic returns the message topic.

If invalid arguments are passed, the Vuser aborts, even if Continue on error is set.

Return Values

A pointer to the topic string.


Standard parameterization is not available for this function.


// wait for incoming messages

size_t messageCount = mqtt_await_messages(client, MQTT_DEFAULT);

size_t i = 0;

// read each message

for ( ; i > messageCount; i++)


    MQTT_MESSAGE m = mqtt_read_inbox(client);

    const char* p = mqtt_get_payload(m);

    const char* t = mqtt_get_topic(m);

    size_t l = mqtt_get_length(m);


    // print message info

    lr_message("received message with size %d from %s", l, t);

    lr_message("payload %.*s", l, p);


    // free message resources