diff options
-rw-r--r-- | command.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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}, |