]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.h
Add duplicate node detection callback.
[meshlink] / src / meshlink.h
index 37eeac81ed0b74a43ebb1ae981bffb2042c46c79..15fb6e6965cedd6569f6de89c30afc00d85eaef3 100644 (file)
@@ -242,6 +242,26 @@ typedef void (*meshlink_node_status_cb_t)(meshlink_handle_t *mesh, meshlink_node
  */
 extern void meshlink_set_node_status_cb(meshlink_handle_t *mesh, meshlink_node_status_cb_t cb);
 
+/// A callback reporting duplicate node detection.
+/** @param mesh       A handle which represents an instance of MeshLink.
+ *  @param node       A pointer to a meshlink_node_t describing the node which is duplicate.
+ *                    This pointer is valid until meshlink_close() is called.
+ */
+typedef void (*meshlink_node_duplicate_cb_t)(meshlink_handle_t *mesh, meshlink_node_t *node);
+
+/// Set the node duplicate callback.
+/** This functions sets the callback that is called whenever a duplicate node is detected.
+ *  The callback is run in MeshLink's own thread.
+ *  It is therefore important that the callback uses apprioriate methods (queues, pipes, locking, etc.)
+ *  to hand the data over to the application's thread.
+ *  The callback should also not block itself and return as quickly as possible.
+ *
+ *  @param mesh      A handle which represents an instance of MeshLink.
+ *  @param cb        A pointer to the function which will be called when a duplicate node is detected.
+ *                   If a NULL pointer is given, the callback will be disabled.
+ */
+extern void meshlink_set_node_duplicate_cb(meshlink_handle_t *mesh, meshlink_node_duplicate_cb_t cb);
+
 /// Severity of log messages generated by MeshLink.
 typedef enum {
        MESHLINK_DEBUG,    ///< Internal debugging messages. Only useful during application development.