[SOLVED] What is the function of client.loop();?

Can someone please tell me what is the function of client.loop();?
I can’t understand what’s the function of this line.

I hope someone can help me.
regards.

Hello @Rehanbabar17,

I suppose you’re referring to MQTT, so the function client.loop() should be called regularly to allow the client to process incoming messages to send publish data and makes a refresh of the connection.

I hope would help you to understand that line.

Best Regards,
Maria C.

Hi @mariahernandez,

When you say regularly does that mean every time a variable/source is published?

For instance like:

client.add(“variable 1”, temperature);
client.add(“variable 2”, humidity);
client.ubidotsPublish(“source1”);
client.loop();
client.add(“variable 3”, pressure);
client.add(“variable 4”, force);
client.ubidotsPublish(“source2”);
client.loop();

Regards

Hey @su1993.

Sorry for the time in hold… No, when I say regularly I mean once on the void loop. So, you just have to call the function client.loop() and the end of the loop.

Please reference to our publish example to get an idea

Regards.