Skip to main content

pamoja_mqtt_client_recv_within

Function pamoja_mqtt_client_recv_within 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_mqtt_client_recv_within( client: *mut PamojaMqttClient, timeout_ms: u64, out_message: *mut *mut PamojaMqttMessage, out_timed_out: *mut bool, ) -> PamojaStatus
Expand description

Waits a limited time for the next message from any subscribed topic.

Running out of time loses nothing: a message that arrives afterwards waits for the next receive. This is the call to use rather than abandoning a receive that is still waiting, which would take that message instead.

§Arguments

  • client - the client.
  • timeout_ms - how long to wait, in milliseconds.
  • out_message - receives a message handle the caller releases with pamoja_mqtt_message_free, or null when the time ran out or the connection has ended.
  • out_timed_out - receives whether the time ran out before a message arrived.

§Returns

PamojaStatus::Ok with a message, with the time run out, or with null once the connection has ended, or an error status.

§Safety

client must be a live handle from pamoja_mqtt_client_new, and out_message and out_timed_out must be writable.