how we can end the session of praticular user in XMPP and logout form the chat

人走茶凉 提交于 2019-12-23 04:18:09

问题


Button logout = (Button) this.findViewById(R.id.btlogout); logout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            connection.disconnect();
            setContentView(R.layout.login);


        }
    });

this code is allowing me logout but not killing the session and the page which i am redirecting that page's button is not working .


回答1:


First of all send presence packet to server and then you should logout. This way your session will be killed.

Presence pr=new Presence(Presence.Type.unavailable);
connection.sendPacket(pr);
connection.disconnect();

it will first made you offline and then after disconnect from server.Hope it will help.Thanks.



来源:https://stackoverflow.com/questions/29028838/how-we-can-end-the-session-of-praticular-user-in-xmpp-and-logout-form-the-chat

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!