]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink++.h
Call srand() at startup.
[meshlink] / src / meshlink++.h
index 30d6ae52234b1c7a4158ccc8d6ece7036b891821..258d6cf49b796b75c42bb3194509223af6d2497d 100644 (file)
@@ -89,6 +89,13 @@ namespace meshlink {
 
        /// A class describing a MeshLink channel.
        class channel: public meshlink_channel_t {
+               public:
+               static const uint32_t RELIABLE = MESHLINK_CHANNEL_RELIABLE;
+               static const uint32_t ORDERED = MESHLINK_CHANNEL_ORDERED;
+               static const uint32_t FRAMED = MESHLINK_CHANNEL_FRAMED;
+               static const uint32_t DROP_LATE = MESHLINK_CHANNEL_DROP_LATE;
+               static const uint32_t TCP = MESHLINK_CHANNEL_TCP;
+               static const uint32_t UDP = MESHLINK_CHANNEL_UDP;
        };
 
        /// A class describing a MeshLink mesh.
@@ -347,6 +354,10 @@ namespace meshlink {
                 *  Also note that if you have a dynamic IP address, or are behind carrier-grade NAT,
                 *  there is no guarantee that the external address will be valid for an extended period of time.
                 *
+                *  This function is blocking. It can take several seconds before it returns.
+                *  There is no guarantee it will be able to resolve the external address.
+                *  Failures might be because by temporary network outages.
+                *
                 *  @return             This function returns a pointer to a C string containing the discovered external address,
                 *                      or NULL if there was an error looking up the address.
                 *                      After get_external_address() returns, the application is free to overwrite or free this string.
@@ -417,6 +428,12 @@ namespace meshlink {
                 *  An invitation can only be used if the local node has never connected to other nodes before.
                 *  After a succesfully accepted invitation, the name of the local node may have changed.
                 *
+                *  This function may only be called on a mesh that has not been started yet and which is not already part of an existing mesh.
+                *
+                *  This function is blocking. It can take several seconds before it returns.
+                *  There is no guarantee it will perform a successful join.
+                *  Failures might be caused by temporary network outages, or by the invitation having expired.
+                *
                 *  @param invitation   A string containing the invitation URL.
                 *
                 *  @return             This function returns true if the local node joined the mesh it was invited to, false otherwise.
@@ -487,11 +504,12 @@ namespace meshlink {
                 *  @param cb           A pointer to the function which will be called when the remote node sends data to the local node.
                 *  @param data         A pointer to a buffer containing data to already queue for sending.
                 *  @param len          The length of the data.
+                *  @param flags        A bitwise-or'd combination of flags that set the semantics for this channel.
                 *
                 *  @return             A handle for the channel, or NULL in case of an error.
                 */
-               channel *channel_open(node *node, uint16_t port, channel_receive_cb_t cb, const void *data, size_t len) {
-                       channel *ch = (channel *)meshlink_channel_open(handle, node, port, (meshlink_channel_receive_cb_t)cb, data, len);
+               channel *channel_open(node *node, uint16_t port, channel_receive_cb_t cb, const void *data, size_t len, uint32_t flags = channel::TCP) {
+                       channel *ch = (channel *)meshlink_channel_open_ex(handle, node, port, (meshlink_channel_receive_cb_t)cb, data, len, flags);
                        meshlink_set_channel_poll_cb(handle, ch, &channel_poll_trampoline);
                        return ch;
                }
@@ -500,8 +518,8 @@ namespace meshlink {
                 * @override
                 * Sets channel_receive_trampoline as cb, which in turn calls this->channel_receive( ... ).
                 */
-               channel *channel_open(node *node, uint16_t port, const void *data, size_t len) {
-                       channel *ch = (channel *)meshlink_channel_open(handle, node, port, &channel_receive_trampoline, data, len);
+               channel *channel_open(node *node, uint16_t port, const void *data, size_t len, uint32_t flags = channel::TCP) {
+                       channel *ch = (channel *)meshlink_channel_open_ex(handle, node, port, &channel_receive_trampoline, data, len, flags);
                        meshlink_set_channel_poll_cb(handle, ch, &channel_poll_trampoline);
                        return ch;
                }