mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 04:57:58 +01:00
Add Chat.close() (SMACK-356)
This commit is contained in:
parent
596008e90a
commit
f73a3afbca
2 changed files with 17 additions and 0 deletions
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue