Check the connection before sending the data.
Signed-off-by: gichan <gichan2.jang@samsung.com>
return NNS_EDGE_ERROR_NONE;
}
+/**
+ * @brief Check whether aitt handle exists or not.
+ */
+int
+nns_edge_aitt_is_connected (nns_edge_h edge_h)
+{
+ nns_edge_handle_s *eh;
+ nns_edge_aitt_handle_s *ah;
+
+ eh = (nns_edge_handle_s *) edge_h;
+
+ if (!NNS_EDGE_MAGIC_IS_VALID (eh)) {
+ nns_edge_loge ("Invalid param, given edge handle is invalid.");
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
+ }
+
+ ah = (nns_edge_aitt_handle_s *) eh->broker_h;
+ if (!ah || !ah->aitt_h) {
+ nns_edge_loge ("AITT handle is not yet connected.");
+ return NNS_EDGE_ERROR_INVALID_PARAMETER;
+ }
+
+ return NNS_EDGE_ERROR_NONE;
+}
+
/**
* @brief Publish raw data.
* @note This is internal function forAITT. You should call this with edge-handle lock.
return NNS_EDGE_ERROR_NONE;
}
+/**
+ * @brief Thread to send data.
+ */
+static int
+_nns_edge_is_connected (nns_edge_h edge_h)
+{
+ nns_edge_handle_s *eh = (nns_edge_handle_s *) edge_h;
+ nns_edge_conn_data_s *conn_data;
+ nns_edge_conn_s *conn;
+ int connection_cnt = 0;
+
+ if (NNS_EDGE_CONNECT_TYPE_AITT == eh->connect_type &&
+ NNS_EDGE_ERROR_NONE == nns_edge_aitt_is_connected (eh))
+ return 1;
+
+ conn_data = (nns_edge_conn_data_s *) eh->connections;
+ while (conn_data) {
+ conn = conn_data->sink_conn;
+ if (_nns_edge_check_connection (conn)) {
+ connection_cnt++;
+ }
+ conn_data = conn_data->next;
+ }
+
+ return connection_cnt;
+}
+
/**
* @brief Send data to desination (broker or connected node), asynchronously.
*/
return NNS_EDGE_ERROR_INVALID_PARAMETER;
}
+ if (0 == _nns_edge_is_connected (eh)) {
+ nns_edge_loge ("There is no available connection.");
+ nns_edge_unlock (eh);
+ return NNS_EDGE_ERROR_IO;
+ }
+
if (!eh->send_thread) {
nns_edge_loge ("Invalid state, start edge before sending a data.");
nns_edge_unlock (eh);
*/
int nns_edge_aitt_close (nns_edge_h edge_h);
+/**
+ * @brief Check whether aitt handle exists or not.
+ */
+int
+nns_edge_aitt_is_connected (nns_edge_h edge_h);
+
/**
* @brief Publish raw data.
* @note This is internal function forAITT. You should call this with edge-handle lock.
#define nns_edge_aitt_close(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_aitt_publish(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#define nns_edge_aitt_subscribe(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_aitt_is_connected(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
#endif
#ifdef __cplusplus