diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-04-16 12:14:54 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-04-16 13:55:34 +0200 |
commit | ca56fc589c46904e44b6836234d7281fcbecbbd6 (patch) | |
tree | d9d20b8fb70f4c72693d460b93ccc63f9a055f34 | |
parent | 95eec6affee455e1ba935a1781495682b2ee7e9a (diff) |
server: Add cmd_logout
-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}, |