Force a Chat to be closed

Hi There,

Im pretty new to smack and I have a problem where I got stuck.

I’d like to close an active chat. Somebody chats with me and I discover that there is no more activity so I release my Chat object by simply

m_Chat.removeMessageListener(this);

m_Chat = null;

Now when the somebody now writes a message again, there is no new chat created and I do not get informed by

ChatManagerListener.chatCreated(Chat chat, boolean createdLocally)

This is because the chat is not garbage collected yet. If I do

m_Chat.removeMessageListener(this);

m_Chat = null;

System.gc();

then chatCreated(…) is called.

Is there a way to do this without calling the garbage collector?

thanks Marcus

There is no way of actually doing this since the chat is maintained as a weak reference. I would not rely on calling gc() as it is unreliable, but at this point there really isn’t an alternative.

I think Chat should contain a close() method that would “disconnect” it as a usable entity. This way the ChatManager could detach the chat and thus create a new one when a new message arrives.

Logged as SMACK-356.

This will solve my problem

Thanks