void myqtt_conn_set_data_full ( MyQttConn connection,
char *  key,
axlPointer  value,
axlDestroyFunc  key_destroy,
axlDestroyFunc  value_destroy 
)

Allows to store user space data into the connection like myqtt_conn_set_data does but configuring functions to be called once required to de-allocate data stored.

While storing user defined data into the connection it could be necessary to also define destroy functions for the value stored and the key stored. This allows to not worry about to free those data (including the key) once the connection is dropped.

This function allows to store data into the given connection defining destroy functions for the key and the value stored, per item.

1 [...]
2 void destroy_data_1 (axlPointer data)
3 {
4  // perform a memory de-allocation for data1
5 }
6 
7 void destroy_data_2 (axlPointer data)
8 {
9  // perform a memory de-allocation for data2
10 }
11 [...]
12 // store data 1 providing a destroy value function
13 myqtt_conn_set_data_full (connection, "some:data:1",
14  data_1, NULL, destroy_data_1);
15 
16 // store data 2 providing a destroy value function
17 myqtt_conn_set_data_full (connection, "some:data:2",
18  data_2, NULL, destroy_data_2);
19 [...]
Parameters
connectionThe connection where the data will be stored.
keyThe unique string key value.
valueThe value to be stored associated to the given key.
key_destroyAn optional key destroy function used to destroy (de-allocate) memory used by the key.
value_destroyAn optional value destroy function used to destroy (de-allocate) memory used by the value.

References myqtt_hash_remove(), and myqtt_hash_replace_full().

Referenced by myqtt_conn_set_data(), and myqtt_web_socket_listener_new().