X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=examples%2Fgroupchat.c;h=ddcbbfa1da96784840c88f269b477d6bbb0dcddd;hb=92bae04187d9ecd7900b5a28154a2c046001a7f3;hp=18e6f6194b0c67fe58a4a5083e09677adbdea34b;hpb=9d23fe58052b3ef971305699a00ea6dbd1111744;p=meshlink-tiny diff --git a/examples/groupchat.c b/examples/groupchat.c index 18e6f61..ddcbbfa 100644 --- a/examples/groupchat.c +++ b/examples/groupchat.c @@ -3,7 +3,7 @@ #include #include -#include "../src/meshlink.h" +#include "../src/meshlink-tiny.h" #include "../src/devtools.h" #define CHAT_PORT 531 @@ -95,48 +95,7 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) { } - if(!strcasecmp(buf, "invite")) { - if(!arg) { - fprintf(stderr, "/invite requires an argument!\n"); - return; - } - - meshlink_submesh_t *s = NULL; - - if(arg1) { - size_t nmemb; - meshlink_submesh_t **submeshes = devtool_get_all_submeshes(mesh, NULL, &nmemb); - - if(!submeshes || !nmemb) { - fprintf(stderr, "Group does not exist!\n"); - return; - } - - for(size_t i = 0; i < nmemb; i++) { - if(!strcmp(arg1, submeshes[i]->name)) { - s = submeshes[i]; - break; - } - } - - free(submeshes); - - if(!s) { - fprintf(stderr, "Group is not yet created!\n"); - return; - } - } - - char *invitation = meshlink_invite(mesh, s, arg); - - if(!invitation) { - fprintf(stderr, "Could not invite '%s': %s\n", arg, meshlink_strerror(meshlink_errno)); - return; - } - - fprintf(stderr, "Invitation for %s: %s\n", arg, invitation); - free(invitation); - } else if(!strcasecmp(buf, "canonical")) { + if(!strcasecmp(buf, "canonical")) { bool set; char *host = NULL, *port = NULL; @@ -209,44 +168,6 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) { fprintf(stderr, "Could not restart MeshLink: %s\n", meshlink_strerror(meshlink_errno)); exit(1); } - } else if(!strcasecmp(buf, "kick")) { - if(!arg) { - fprintf(stderr, "/kick requires an argument!\n"); - return; - } - - meshlink_node_t *node = meshlink_get_node(mesh, arg); - - if(!node) { - fprintf(stderr, "Error looking up '%s': %s\n", arg, meshlink_strerror(meshlink_errno)); - return; - } - - if(!meshlink_blacklist(mesh, node)) { - fprintf(stderr, "Error blacklising '%s': %s", arg, meshlink_strerror(meshlink_errno)); - return; - } - - fprintf(stderr, "Node '%s' blacklisted.\n", arg); - } else if(!strcasecmp(buf, "whitelist")) { - if(!arg) { - fprintf(stderr, "/whitelist requires an argument!\n"); - return; - } - - meshlink_node_t *node = meshlink_get_node(mesh, arg); - - if(!node) { - fprintf(stderr, "Error looking up '%s': %s\n", arg, meshlink_strerror(meshlink_errno)); - return; - } - - if(!meshlink_whitelist(mesh, node)) { - fprintf(stderr, "Error whitelising '%s': %s", arg, meshlink_strerror(meshlink_errno)); - return; - } - - fprintf(stderr, "Node '%s' whitelisted.\n", arg); } else if(!strcasecmp(buf, "who")) { meshlink_submesh_t *node_group = NULL; @@ -344,8 +265,6 @@ static void parse_command(meshlink_handle_t *mesh, char *buf) { ": Send a message to the given node.\n" " Subsequent messages don't need the : prefix.\n" "/group Create a new group" - "/invite [submesh] Create an invitation for a new node.\n" - " Node joins either coremesh or submesh depending on submesh parameter.\n" "/join Join an existing mesh using an invitation.\n" "/kick Blacklist the given node.\n" "/who [] List all nodes or show information about the given node.\n"