(void)peer;
}
+ /// This functions is called whenever the MeshLink thread status changes.
+ virtual void thread_status(bool status) {
+ /* do nothing */
+ (void)status;
+ }
+
/// This functions is called whenever MeshLink a meta-connection attempt is made.
virtual void connection_try(node *peer) {
/* do nothing */
meshlink_set_log_cb(handle, MESHLINK_DEBUG, &log_trampoline);
meshlink_set_error_cb(handle, &error_trampoline);
meshlink_set_blacklisted_cb(handle, &blacklisted_trampoline);
+ meshlink_set_thread_status_cb(handle, &thread_status_trampoline);
meshlink_set_channel_listen_cb(handle, &channel_listen_trampoline);
meshlink_set_channel_accept_cb(handle, &channel_accept_trampoline);
meshlink_set_connection_try_cb(handle, &connection_try_trampoline);
return meshlink_get_node_blacklisted(handle, node);
}
+ /// Get the node's tiny status.
+ /** This function returns true if the given node is a tiny node.
+ * Note that the tiny status of a node will only be known if the node has been reachable at least once.
+ *
+ * @param node A pointer to a meshlink::node describing the node.
+ *
+ * @return This function returns true if the node is a tiny node.
+ */
+ bool get_node_tiny(node *node) {
+ return meshlink_get_node_tiny(handle, node);
+ }
+
/// Get a handle for a specific submesh.
/** This function returns a handle for the submesh with the given name.
*
* It also causes the local node to stop accepting incoming data from the remote node.
* Afterwards, the channel handle is invalid and must not be used any more.
*
+ * It is allowed to call this function at any time on a valid handle, even inside callback functions.
+ * If called with a valid handle, this function always succeeds, otherwise the result is undefined.
+ *
* @param channel A handle for the channel.
*/
void channel_close(meshlink_channel_t *channel) {
return meshlink_channel_close(handle, channel);
}
+ /// Abort a reliable stream channel.
+ /** This aborts a channel.
+ * Data that was in the send and receive buffers is dropped, so potentially there is some data that
+ * was sent on this channel that will not be received by the peer.
+ * Afterwards, the channel handle is invalid and must not be used any more.
+ *
+ * It is allowed to call this function at any time on a valid handle, even inside callback functions.
+ * If called with a valid handle, this function always succeeds, otherwise the result is undefined.
+ *
+ * @param channel A handle for the channel.
+ */
+ void channel_abort(meshlink_channel_t *channel) {
+ return meshlink_channel_abort(handle, channel);
+ }
+
/// Transmit data on a channel
/** This queues data to send to the remote node.
*
meshlink_enable_discovery(handle, enable);
}
+ /// Inform MeshLink that the local network configuration might have changed
+ /** This is intended to be used when there is no way for MeshLink to get notifications of local network changes.
+ * It forces MeshLink to scan all network interfaces for changes in up/down status and new/removed addresses,
+ * and will immediately check if all connections to other nodes are still alive.
+ */
+ void hint_network_change() {
+ meshlink_hint_network_change(handle);
+ }
+
/// Set device class timeouts
/** This sets the ping interval and timeout for a given device class.
*
that->blacklisted(static_cast<node *>(peer));
}
+ static void thread_status_trampoline(meshlink_handle_t *handle, bool status) {
+ if(!(handle->priv)) {
+ return;
+ }
+
+ meshlink::mesh *that = static_cast<mesh *>(handle->priv);
+ that->thread_status(status);
+ }
+
static void connection_try_trampoline(meshlink_handle_t *handle, meshlink_node_t *peer) {
if(!(handle->priv)) {
return;