Smack:How to avoid leave the chat room

If logout or no connection,user will leave the chat room.I want to avoid leaving,how to do?Give me help.

Or like this openfire - XMPP receive history without rejoining the MUC - Stack Overflow

@Flow