7 volatile bool baz_reachable = false;
9 void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
10 if(!strcmp(node->name, "baz"))
11 baz_reachable = reachable;
14 int main(int argc, char *argv[]) {
15 // Open two new meshlink instance.
17 meshlink_handle_t *mesh1 = meshlink_open("invite_join_conf.1", "foo");
21 meshlink_handle_t *mesh2 = meshlink_open("invite_join_conf.2", "bar");
25 // Start the first instance and have it generate an invitation.
27 meshlink_set_node_status_cb(mesh1, status_cb);
29 if(!meshlink_start(mesh1))
32 meshlink_add_address(mesh1, "localhost");
33 char *url = meshlink_invite(mesh1, "baz");
37 // Have the second instance join the first.
39 if(!meshlink_join(mesh2, url))
44 if(!meshlink_start(mesh2))
47 // Wait for the two to connect.
49 for(int i = 0; i < 20; i++) {
62 meshlink_close(mesh2);
63 meshlink_close(mesh1);