X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fmeshlink%2B%2B.h;h=eeb1cd02ac1793921139e0e8285d7d2cd1fa593f;hb=HEAD;hp=1f109849b6408e5cd7487f4365c92b3493a32185;hpb=afea9096fa708b2a2e6e24c308c0f1a80eefa5cc;p=meshlink diff --git a/src/meshlink++.h b/src/meshlink++.h index 1f109849..9e97fc82 100644 --- a/src/meshlink++.h +++ b/src/meshlink++.h @@ -280,6 +280,12 @@ public: (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 */ @@ -381,6 +387,7 @@ public: 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); @@ -449,6 +456,18 @@ public: 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. * @@ -1012,12 +1031,30 @@ public: * 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. * @@ -1150,6 +1187,15 @@ public: 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. * @@ -1274,6 +1320,15 @@ private: that->blacklisted(static_cast(peer)); } + static void thread_status_trampoline(meshlink_handle_t *handle, bool status) { + if(!(handle->priv)) { + return; + } + + meshlink::mesh *that = static_cast(handle->priv); + that->thread_status(status); + } + static void connection_try_trampoline(meshlink_handle_t *handle, meshlink_node_t *peer) { if(!(handle->priv)) { return;