Added ability to create a chat with a prior specified threadID.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@6241 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Alex Wenckus 2006-11-28 18:46:40 +00:00 committed by alex
parent 355bd56d85
commit 4279a4acf8
1 changed files with 21 additions and 3 deletions

View File

@ -121,11 +121,29 @@ public class ChatManager {
* @return the created chat.
*/
public Chat createChat(String userJID, MessageListener listener) {
String threadID = nextID();
String threadID;
do {
threadID = nextID();
} while (threadChats.get(threadID) != null);
Chat chat = createChat(userJID, threadID, true);
return createChat(userJID, threadID, listener);
}
/**
* Creates a new chat using the specified thread ID, then returns it.
*
* @param userJID the jid of the user this chat is with
* @param thread the thread of the created chat.
* @param listener the listener to add to the chat
* @return the created chat.
*/
public Chat createChat(String userJID, String thread, MessageListener listener) {
Chat chat = threadChats.get(thread);
if(chat != null) {
throw new IllegalArgumentException("ThreadID is already used");
}
chat = createChat(userJID, thread, true);
chat.addMessageListener(listener);
return chat;
}