Properly leave a chat room in smack Android -
in appilcation using below method leave chat room.
public void leavechatroom(string username) { log.i("xmpp chat client", "user left chat room "); if(groupchat != null && groupchat.isjoined()) { try { presence leavepresence = new presence(presence.type.unavailable); leavepresence.setto("groupchat@conference.xxx/" + username); connection.sendpacket(leavepresence); groupchat.leave(); } catch (notconnectedexception e) { e.printstacktrace(); } } }
and check whether user joined or not,
public boolean isjoinedgroup(string username) { boolean isconnected = false; if(groupchat != null && groupchat.isjoined()) { isconnected = true; log.i("xmpp chat client", "joined true"); } return isconnected; }
this works fine if there successful chat server connection. in cases chat server connection loses. in situation, have make user leave chat room , join again automatically. when lose chat server connection, reconnect chat server , call leavechatroom
method , join group
method together. getting notconnectedexception
in line groupchat.leave();
, when check joined status,it returns true. when checked openfire admin panel, there no user in groupchat occupants list. how can remove user groupchat in situation?
Comments
Post a Comment