BEGIN_C_DECLS MyQttConn * myqtt_web_socket_conn_new ( MyQttCtx ctx,
const char *  client_identifier,
axl_bool  clean_session,
int  keep_alive,
noPollConn *  conn,
MyQttConnOpts opts,
MyQttConnNew  on_connected,
axlPointer  user_data 
)

Allows to create a new MQTT connection to a MQTT broker/server running MQTT over WebSocket.

Parameters
ctxThe context where the operation will take place.
client_identifierThe client identifier that uniquely identifies this MQTT client from others. It can be NULL to let MQTT 3.1.1 servers to assign a default client identifier BUT clean_session must be set to axl_true. This is done automatically by the library (setting clean_session to axl_true when NULL is provided).
clean_sessionFlag to clean client session or to reuse the existing one. If set to axl_false, you must provide a valid client_identifier (otherwise the function will fail).
keep_aliveKeep alive configuration in seconds after which the server/broker will close the connection if it doesn't detect any activity. Setting 0 will disable keep alive mechanism.
connA reference to an established noPollConn connection that is connecting to the MQTT over WebSocket server we want to connect to.
optsOptional connection options. See myqtt_conn_opts_new
on_connectedAsync notification handler that will be called once the connection fails or it is completed. In the case this handler is configured the caller will not be blocked. In the case this parameter is NULL, the caller will be blocked until the connection completes or fails.
user_dataUser defined pointer that will be passed to the on_connected handler (in case it is defined).
Returns
A reference to the newli created connection or NULL if on_connected handler is provided. In both cases, the reference returned (or received at the on_connected handler) must be checked with myqtt_conn_is_ok.

About pending messages / queued messages

After successful connection with clean_session set to axl_false and defined client identifier, the library will resend any queued or in flight QoS1/QoS2 messages (as well as QoS0 if they were stored). This is done in background without intefering the caller.

If you need to get the number of queued messages that are going to be sent use myqtt_storage_queued_messages_offline. In the case you need the number remaining during the process use myqtt_storage_queued_messages.

See myqtt_conn_new for more information.

About reconnecting

If you enable automatic reconnect support after connection close (myqtt_conn_opts_set_reconnect), remember to also configure the recover handler by using myqtt_conn_opts_set_init_session_setup_ptr. That function should implement a complete reconnect and return a noPollConn reference used by the internal session setup. If you don't configure this, the function will disable reconnect support even if you enable it.