]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink++.h
Never automatically try to bind to ports >= 32768.
[meshlink] / src / meshlink++.h
index baf08ae1ef15405aa238360bfbb69a1f2309c5a0..9e97fc820d846b29e9570da08bbc1fb47b65e4bd 100644 (file)
@@ -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.
         *
@@ -1283,6 +1320,15 @@ private:
                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;