-
Notifications
You must be signed in to change notification settings - Fork 886
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ramabit.tbr.opt2
- Loading branch information
Showing
10 changed files
with
173 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,19 @@ text-based conference rooms. | |
|
||
**XEP related:** [XEP-45](http://www.xmpp.org/extensions/xep-0045.html) | ||
|
||
For all examples in this document, assume that the following variables exists: | ||
|
||
```java | ||
// Create the XMPP address (JID) of the MUC. | ||
EntityBareJid mucJid = JidCreate.bareFrom("[email protected]"); | ||
|
||
// Create the nickname. | ||
Resourcepart nickname = Resourcepart.from("testbot"); | ||
|
||
// A other use (we may invite him to a MUC). | ||
FullJid otherJid = JidCreate.fullFromm("[email protected]/Smack"); | ||
``` | ||
|
||
Create a new Room | ||
----------------- | ||
|
||
|
@@ -52,10 +65,10 @@ In this example we can see how to create an instant room: | |
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection); | ||
|
||
// Get a MultiUserChat using MultiUserChatManager | ||
MultiUserChat muc = manager.getMultiUserChat("[email protected]"); | ||
MultiUserChat muc = manager.getMultiUserChat(mucJid); | ||
|
||
// Create the room and send an empty configuration form to make this an instant room | ||
muc.create("testbot").makeInstant(); | ||
muc.create(nickname).makeInstant(); | ||
``` | ||
|
||
In this example we can see how to create a reserved room. The form is | ||
|
@@ -66,13 +79,13 @@ completed with default values: | |
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection); | ||
|
||
// Create a MultiUserChat using an XMPPConnection for a room | ||
MultiUserChat muc = = manager.getMultiUserChat("[email protected]"); | ||
MultiUserChat muc = = manager.getMultiUserChat(mucJid); | ||
|
||
// Prepare a list of owners of the new room | ||
Set<Jid> owners = JidUtil.jidSetFrom(new String[] { "[email protected]", "[email protected]" }); | ||
|
||
// Create the room | ||
muc.create("testbot") | ||
muc.create(nickname) | ||
.getConfigFormManger() | ||
.setRoomOwners(owners) | ||
.submitConfigurationForm(); | ||
|
@@ -116,11 +129,11 @@ In this example we can see how to join a room with a given nickname: | |
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection); | ||
|
||
// Create a MultiUserChat using an XMPPConnection for a room | ||
MultiUserChat muc2 = manager.getMultiUserChat("[email protected]"); | ||
MultiUserChat muc2 = manager.getMultiUserChat(mucJid); | ||
|
||
// User2 joins the new room | ||
// The room service will decide the amount of history to send | ||
muc2.join("testbot2"); | ||
muc2.join(nickname); | ||
``` | ||
|
||
In this example we can see how to join a room with a given nickname and | ||
|
@@ -131,11 +144,11 @@ password: | |
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection); | ||
|
||
// Create a MultiUserChat using an XMPPConnection for a room | ||
MultiUserChat muc2 = manager.getMultiUserChat("[email protected]"); | ||
MultiUserChat muc2 = manager.getMultiUserChat(mucJid); | ||
|
||
// User2 joins the new room using a password | ||
// The room service will decide the amount of history to send | ||
muc2.join("testbot2", "password"); | ||
muc2.join(nickname, "password"); | ||
``` | ||
|
||
In this example we can see how to join a room with a given nickname specifying | ||
|
@@ -146,13 +159,13 @@ the amount of history to receive: | |
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection); | ||
|
||
// Create a MultiUserChat using an XMPPConnection for a room | ||
MultiUserChat muc2 = manager.getMultiUserChat("[email protected]"); | ||
MultiUserChat muc2 = manager.getMultiUserChat(mucJid); | ||
|
||
// User2 joins the new room using a password and specifying | ||
// the amount of history to receive. In this example we are requesting the last 5 messages. | ||
DiscussionHistory history = new DiscussionHistory(); | ||
history.setMaxStanzas(5); | ||
muc2.join("testbot2", "password", history, conn1.getPacketReplyTimeout()); | ||
muc2.join(nickname, "password", history, conn1.getPacketReplyTimeout()); | ||
``` | ||
|
||
Manage room invitations | ||
|
@@ -193,17 +206,17 @@ for possible rejections: | |
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection); | ||
|
||
// Create a MultiUserChat using an XMPPConnection for a room | ||
MultiUserChat muc2 = manager.getMultiUserChat("[email protected]"); | ||
MultiUserChat muc2 = manager.getMultiUserChat(mucJid); | ||
|
||
muc2.join("testbot2"); | ||
muc2.join(nickname); | ||
// User2 listens for invitation rejections | ||
muc2.addInvitationRejectionListener(new InvitationRejectionListener() { | ||
public void invitationDeclined(String invitee, String reason) { | ||
// Do whatever you need here... | ||
} | ||
}); | ||
// User2 invites user3 to join to the room | ||
muc2.invite("[email protected]/Smack", "Meet me in this excellent room"); | ||
muc2.invite(otherJid, "Meet me in this excellent room"); | ||
``` | ||
|
||
In this example we can see how to listen for room invitations and decline | ||
|
@@ -212,9 +225,9 @@ invitations: | |
```java | ||
// User3 listens for MUC invitations | ||
MultiUserChatManager.getInstanceFor(connection).addInvitationListener(new InvitationListener() { | ||
public void invitationReceived(XMPPConnection conn, String room, String inviter, String reason, String password) { | ||
public void invitationReceived(XMPPConnection conn, String room, EntityFullJid inviter, String reason, String password) { | ||
// Reject the invitation | ||
MultiUserChat.decline(conn, room, inviter, "I'm busy right now"); | ||
MultiUserChat.decline(conn, room, inviter.asBareJid()s, "I'm busy right now"); | ||
} | ||
}); | ||
``` | ||
|
@@ -241,7 +254,7 @@ In this example we can see how to discover support of MUC: | |
|
||
```java | ||
// Discover whether [email protected] supports MUC or not | ||
boolean supports = MultiUserChatManager.getInstanceFor(connection).isServiceEnabled("[email protected]/Smack"); | ||
boolean supports = MultiUserChatManager.getInstanceFor(connection).isServiceEnabled(otherJid); | ||
``` | ||
|
||
Discover joined rooms | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ | |
|
||
package org.jivesoftware.smackx.muc; | ||
|
||
import org.jivesoftware.smack.packet.Message; | ||
import org.jivesoftware.smackx.muc.packet.MUCUser; | ||
import org.jxmpp.jid.EntityBareJid; | ||
|
||
/** | ||
* A listener that is fired anytime an invitee declines or rejects an invitation. | ||
* | ||
|
@@ -29,7 +33,9 @@ public interface InvitationRejectionListener { | |
* | ||
* @param invitee the invitee that declined the invitation. (e.g. [email protected]). | ||
* @param reason the reason why the invitee declined the invitation. | ||
* @param message the message used to decline the invitation. | ||
* @param rejection the raw decline found in the message. | ||
*/ | ||
public abstract void invitationDeclined(String invitee, String reason); | ||
public abstract void invitationDeclined(EntityBareJid invitee, String reason, Message message, MUCUser.Decline rejection); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.