From 0293ca2bcd55986a81e84534e05e1e3b7218dbfb Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 26 Dec 2014 18:21:38 +0100 Subject: [PATCH] Add MultiUserChat.createOrJoin(String,String,DiscussionHistory,long) --- .../smackx/muc/MultiUserChat.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java index 33e73d4fa..a02914d08 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java @@ -357,6 +357,22 @@ public class MultiUserChat { throw new SmackException("Creation failed - Missing acknowledge of room creation."); } + /** + * Same as {@link #createOrJoin(String, String, DiscussionHistory, long)}, but without a password, specifying a + * discussion history and using the connections default reply timeout. + * + * @param nickname + * @return true if the room creation was acknowledged by the service, false otherwise. + * @throws NoResponseException + * @throws XMPPErrorException + * @throws SmackException + * @see #createOrJoin(String, String, DiscussionHistory, long) + */ + public synchronized boolean createOrJoin(String nickname) throws NoResponseException, XMPPErrorException, + SmackException { + return createOrJoin(nickname, null, null, connection.getPacketReplyTimeout()); + } + /** * Like {@link #create(String)}, but will return true if the room creation was acknowledged by * the service (with an 201 status code). It's up to the caller to decide, based on the return @@ -364,17 +380,21 @@ public class MultiUserChat { * already existed and the user is able to join right away, without sending a form. * * @param nickname the nickname to use. + * @param password the password to use. + * @param history the amount of discussion history to receive while joining a room. + * @param timeout the amount of time to wait for a reply from the MUC service(in milliseconds). * @return true if the room creation was acknowledged by the service, false otherwise. * @throws XMPPErrorException if the room couldn't be created for some reason (e.g. 405 error if * the user is not allowed to create the room) * @throws NoResponseException if there was no response from the server. */ - public synchronized boolean createOrJoin(String nickname) throws NoResponseException, XMPPErrorException, SmackException { + public synchronized boolean createOrJoin(String nickname, String password, DiscussionHistory history, long timeout) + throws NoResponseException, XMPPErrorException, SmackException { if (joined) { throw new IllegalStateException("Creation failed - User already joined the room."); } - Presence presence = enter(nickname, null, null, connection.getPacketReplyTimeout()); + Presence presence = enter(nickname, password, history, timeout); // Look for confirmation of room creation from the server MUCUser mucUser = MUCUser.from(presence);