]> git.meshlink.io Git - meshlink/commitdiff
Restart the mesh after a failed join() in the other examples as well.
authorGuus Sliepen <guus@meshlink.io>
Thu, 6 Jul 2017 20:08:37 +0000 (22:08 +0200)
committerGuus Sliepen <guus@meshlink.io>
Thu, 6 Jul 2017 20:08:37 +0000 (22:08 +0200)
examples/chat.c
examples/chatpp.cc
examples/manynodes.c

index c6d67fb5c1ba2c111d4c814fdc1971699dc85ccc..37e067345f1561c1ac3fda2cbb53147f7c6b1d4c 100644 (file)
@@ -65,12 +65,11 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) {
                meshlink_stop(mesh);
                if(!meshlink_join(mesh, arg))
                        fprintf(stderr, "Could not join using invitation: %s\n", meshlink_strerror(meshlink_errno));
-               else {
+               else
                        fprintf(stderr, "Invitation accepted!\n");
-                       if(!meshlink_start(mesh)) {
-                               fprintf(stderr, "Could not start MeshLink: %s\n", meshlink_strerror(meshlink_errno));
-                       return;
-                       }
+               if(!meshlink_start(mesh)) {
+                       fprintf(stderr, "Could not restart MeshLink: %s\n", meshlink_strerror(meshlink_errno));
+                       exit(1);
                }
        } else if(!strcasecmp(buf, "kick")) {
                if(!arg) {
index 33a1cac538f90d66ee12d8dddea59182c5d4b9f9..97f8740639836591beabb294b8b5c851df1e0a5e 100644 (file)
@@ -61,10 +61,17 @@ static void parse_command(meshlink::mesh *mesh, char *buf) {
                        return;
                }
 
+               mesh->stop();
+
                if(!mesh->join(arg))
                        fprintf(stderr, "Could not join using invitation: %s\n", meshlink::strerror());
                else
                        fprintf(stderr, "Invitation accepted!\n");
+
+               if(!mesh->start()) {
+                       fprintf(stderr, "Could not restart MeshLink: %s\n", meshlink::strerror());
+                       exit(1);
+               }
        } else if(!strcasecmp(buf, "kick")) {
                if(!arg) {
                        fprintf(stderr, "/kick requires an argument!\n");
index f0fc22da8443621dc448a96dc1410a0b2b240bd4..0aafbcef25c661aa03a0825783ffdb119ffe5ce8 100644 (file)
@@ -221,7 +221,10 @@ static void parse_command(char *buf) {
                        fprintf(stderr, "Could not join using invitation: %s\n", meshlink_strerror(meshlink_errno));
                else {
                        fprintf(stderr, "Invitation accepted!\n");
-                       meshlink_start(mesh[nodeindex]);
+               }
+               if(!meshlink_start(mesh[nodeindex])) {
+                       fprintf(stderr, "Could not restart MeshLink: %s\n", meshlink_strerror(meshlink_errno));
+                       exit(1);
                }
        } else if(!strcasecmp(buf, "kick")) {
                if(!arg) {