1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 22:32:06 +01:00

Add Chat.close() (SMACK-356)

This commit is contained in:
Florian Schmaus 2014-03-17 09:14:17 +01:00
parent 596008e90a
commit f73a3afbca
2 changed files with 17 additions and 0 deletions

View file

@ -128,6 +128,16 @@ public class Chat {
listeners.remove(listener);
}
/**
* Closes the Chat and removes all references to it from the {@link ChatManager}. The chat will
* be unusable when this method returns, so it's recommend to drop all references to the
* instance right after calling {@link #close()}.
*/
public void close() {
chatManager.closeChat(this);
listeners.clear();
}
/**
* Returns an unmodifiable collection of all of the listeners registered with this chat.
*

View file

@ -227,6 +227,13 @@ public class ChatManager {
return chat;
}
void closeChat(Chat chat) {
threadChats.remove(chat.getThreadID());
String userJID = chat.getParticipant();
jidChats.remove(userJID);
baseJidChats.remove(StringUtils.parseBareAddress(userJID));
}
private Chat createChat(Message message) {
String threadID = message.getThread();
if(threadID == null) {