1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 22:12:05 +01:00

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

View file

@ -121,11 +121,29 @@ public class ChatManager {
* @return the created chat. * @return the created chat.
*/ */
public Chat createChat(String userJID, MessageListener listener) { 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); chat.addMessageListener(listener);
return chat; return chat;
} }