From ca56fc589c46904e44b6836234d7281fcbecbbd6 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 16 Apr 2017 12:14:54 +0200 Subject: server: Add cmd_logout --- command.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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}, -- cgit v1.2.3-70-g09d2