]> git.meshlink.io Git - meshlink/commitdiff
Register channel poll callback to notify when a channel has succesfully opened.
authorGuus Sliepen <guus@meshlink.io>
Fri, 31 Oct 2014 08:11:49 +0000 (09:11 +0100)
committerGuus Sliepen <guus@meshlink.io>
Fri, 31 Oct 2014 08:11:49 +0000 (09:11 +0100)
examples/channels.c

index b9dd8a256f8214b21110184b892be0e421dd8a14..6d34de360b2991e3bc985d2dff5d23ef68b419e6 100644 (file)
@@ -55,6 +55,11 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel,
        return true;
 }
 
+static void channel_poll(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
+       fprintf(stderr, "Channel to '%s' connected\n", channel->node->name);
+       meshlink_set_channel_poll_cb(mesh, channel, NULL);
+}
+
 static void node_status(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
        if(reachable)
                printf("%s joined.\n", node->name);
@@ -215,6 +220,7 @@ static void parse_input(meshlink_handle_t *mesh, char *buf) {
                        return;
                }
                destination->priv = channel;
+               meshlink_set_channel_poll_cb(mesh, channel, channel_poll);
        }
 
        if(!meshlink_channel_send(mesh, channel, msg, strlen(msg))) {