[][src]Function paho_mqtt_sys::MQTTAsync_create

pub unsafe extern "C" fn MQTTAsync_create(
    handle: *mut MQTTAsync,
    serverURI: *const c_char,
    clientId: *const c_char,
    persistence_type: c_int,
    persistence_context: *mut c_void
) -> c_int

This function creates an MQTT client ready for connection to the specified server and using the specified persistent storage (see MQTTAsync_persistence). See also MQTTAsync_destroy(). @param handle A pointer to an ::MQTTAsync handle. The handle is populated with a valid client reference following a successful return from this function. @param serverURI A null-terminated string specifying the server to which the client will connect. It takes the form protocol://host:port. protocol must be tcp or ssl. For host, you can specify either an IP address or a host name. For instance, to connect to a server running on the local machines with the default MQTT port, specify tcp://localhost:1883. @param clientId The client identifier passed to the server when the client connects to it. It is a null-terminated UTF-8 encoded string. @param persistence_type The type of persistence to be used by the client:
::MQTTCLIENT_PERSISTENCE_NONE: Use in-memory persistence. If the device or system on which the client is running fails or is switched off, the current state of any in-flight messages is lost and some messages may not be delivered even at QoS1 and QoS2.
::MQTTCLIENT_PERSISTENCE_DEFAULT: Use the default (file system-based) persistence mechanism. Status about in-flight messages is held in persistent storage and provides some protection against message loss in the case of unexpected failure.
::MQTTCLIENT_PERSISTENCE_USER: Use an application-specific persistence implementation. Using this type of persistence gives control of the persistence mechanism to the application. The application has to implement the MQTTClient_persistence interface. @param persistence_context If the application uses ::MQTTCLIENT_PERSISTENCE_NONE persistence, this argument is unused and should be set to NULL. For ::MQTTCLIENT_PERSISTENCE_DEFAULT persistence, it should be set to the location of the persistence directory (if set to NULL, the persistence directory used is the working directory). Applications that use ::MQTTCLIENT_PERSISTENCE_USER persistence set this argument to point to a valid MQTTClient_persistence structure. @return ::MQTTASYNC_SUCCESS if the client is successfully created, otherwise an error code is returned.