]> git.meshlink.io Git - meshlink/commitdiff
Call meshlink_stop before meshlink_join in the chat program
authorSaverio Proto <zioproto@gmail.com>
Thu, 7 Aug 2014 14:18:38 +0000 (14:18 +0000)
committerSaverio Proto <zioproto@gmail.com>
Thu, 7 Aug 2014 14:19:55 +0000 (14:19 +0000)
examples/chat.c

index ace1e783883a4176d9516e34efbc74147a336edb..1a3343288a6c7699ada71e27da5cb4260462828c 100644 (file)
@@ -56,11 +56,16 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) {
                        fprintf(stderr, "/join requires an argument!\n");
                        return;
                }
-
+               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 1;
+                       }
+               }
        } else if(!strcasecmp(buf, "kick")) {
                if(!arg) {
                        fprintf(stderr, "/kick requires an argument!\n");