aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--command.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/command.c b/command.c
index 1bbde10..2a75e7f 100644
--- a/command.c
+++ b/command.c
@@ -53,6 +53,17 @@ static bool cmd_login(struct conn_data *data,const char *tag,const char **args){
return false;
}
+static bool cmd_logout(struct conn_data *data,const char *tag,const char **args){
+ (void)args;
+ if(data->userid!=-1){
+ userdata_unregister(data->userid,data->fd);
+ broadcast_online_change(data->userid);
+ data->userid=-1;
+ }
+ net_send_ok(data->fd,tag);
+ return false;
+}
+
static bool cmd_list_rooms(struct conn_data *data,const char *tag,const char **args){
(void)args;
if(data->userid==-1){
@@ -288,6 +299,7 @@ struct cmd_info{
static const struct cmd_info commands[]={
{"register",2,true,cmd_register},
{"login",2,true,cmd_login},
+ {"logout",0,false,cmd_logout},
{"list_rooms",0,false,cmd_list_rooms},
{"list_members",1,false,cmd_list_members},
{"create_room",0,false,cmd_create_room},