diff --git a/src/server.c b/src/server.c index 9fb2f8f..e6e8585 100644 --- a/src/server.c +++ b/src/server.c @@ -308,6 +308,27 @@ int cmd_hello(int sender_id) { return 0; } +/* Function for CMD_SET_GROUP */ +int cmd_set_group(int sender_id, char* name) { + int group_id; + + if ((clients[sender_id].id == -1) || (clients[sender_id].id != sender_id)) { + fprintf(stderr, "Received invalid sender id \"%d\"\n", sender_id); + return -1; + } + if ((strlen(name) == 0) || (strlen(name) > MAX_NAME_LENGTH)) { + fprintf(stderr, "Received invalid name \"%s\"\n", name); + return -1; + } + + // TODO: finish get_group_id_from_name + group_id = 0; + + groups[group_id].clients[sender_id] = 1; + + return 0; +} + /* Function for CMD_SET_NAME */ int cmd_set_name(int sender_id, char* name){ char buf[BUF_LEN]; diff --git a/src/server.h b/src/server.h index 2f5ff89..0aa58fe 100644 --- a/src/server.h +++ b/src/server.h @@ -47,6 +47,9 @@ int cmd_help(int); /* Function for CMD_HELLO */ int cmd_hello(int); +/* Function for CMD_SET_GROUP */ +int cmd_set_group(int, char*); + /* Function for CMD_SET_NAME */ int cmd_set_name(int, char*);