From: Guus Sliepen Date: Fri, 31 Oct 2014 08:11:49 +0000 (+0100) Subject: Register channel poll callback to notify when a channel has succesfully opened. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=d3a67a03a279c2a9e9a32138292e03a445ab5497;p=meshlink Register channel poll callback to notify when a channel has succesfully opened. --- diff --git a/examples/channels.c b/examples/channels.c index b9dd8a25..6d34de36 100644 --- a/examples/channels.c +++ b/examples/channels.c @@ -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))) {