Class MultiUserChatManager
Use getMultiUserChat(EntityBareJid)
to retrieve an object representing a Multi-User Chat room.
Automatic rejoin: The manager supports automatic rejoin of MultiUserChat rooms once the connection got
re-established. This mechanism is disabled by default. To enable it, use setAutoJoinOnReconnect(boolean)
.
You can set a AutoJoinFailedCallback
via setAutoJoinFailedCallback(AutoJoinFailedCallback)
to get
notified if this mechanism failed for some reason. Note that as soon as rejoining for a single room failed, no
further attempts will be made for the other rooms.
DirectMucInvitationManager
which provides an implementation of XEP-0249: Direct MUC Invitations.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
addDefaultMessageInterceptor
(MucMessageInterceptor messageInterceptor) void
addInvitationListener
(InvitationListener listener) Adds a listener to invitation notifications.void
decline
(EntityBareJid room, EntityBareJid inviter, String reason) Informs the sender of an invitation that the invitee declines the invitation.static MultiUserChatManager
getInstanceFor
(XMPPConnection connection) Get a instance of a multi user chat manager for the given connection.Returns a Set of the rooms where the user has joined.getJoinedRooms
(EntityFullJid user) Returns a List of the rooms where the requested user has joined.Returns a collection with the XMPP addresses of the Multi-User Chat services.Creates a multi user chat.getRoomInfo
(EntityBareJid room) Returns the discovered information of a given room without actually having to join the room.getRoomsHostedBy
(DomainBareJid serviceName) Returns a Map of HostedRooms where each HostedRoom has the XMPP address of the room and the room's name.boolean
isServiceEnabled
(Jid user) Returns true if the specified user supports the Multi-User Chat protocol.boolean
providesMucService
(DomainBareJid domainBareJid) Check if the provided domain bare JID provides a MUC service.static boolean
removeDefaultMessageInterceptor
(MucMessageInterceptor messageInterceptor) void
removeInvitationListener
(InvitationListener listener) Removes a listener to invitation notifications.void
setAutoJoinFailedCallback
(AutoJoinFailedCallback failedCallback) Set a callback invoked by this manager when automatic join on reconnect failed.void
setAutoJoinOnReconnect
(boolean autoJoin) If automatic join on reconnect is enabled, then the manager will try to auto join MUC rooms after the connection got re-established.void
setAutoJoinSuccessCallback
(AutoJoinSuccessCallback successCallback) Set a callback invoked by this manager when automatic join on reconnect success.Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
Method Details
-
getInstanceFor
Get a instance of a multi user chat manager for the given connection.- Parameters:
connection
- TODO javadoc me please- Returns:
- a multi user chat manager.
-
getMultiUserChat
Creates a multi user chat. Note: no information is sent to or received from the server until you attempt tojoin
the chat room. On some server implementations, the room will not be created until the first person joins it.Most XMPP servers use a sub-domain for the chat service (e.g.chat.example.com for the XMPP server example.com). You must ensure that the room address you're trying to connect to includes the proper chat sub-domain.
- Parameters:
jid
- the name of the room in the form "roomName@service", where "service" is the hostname at which the multi-user chat service is running. Make sure to provide a valid JID.- Returns:
- MultiUserChat instance of the room with the given jid.
-
addDefaultMessageInterceptor
-
removeDefaultMessageInterceptor
-
isServiceEnabled
public boolean isServiceEnabled(Jid user) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Returns true if the specified user supports the Multi-User Chat protocol.- Parameters:
user
- the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.- Returns:
- a boolean indicating whether the specified user supports the MUC protocol.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getJoinedRooms
Returns a Set of the rooms where the user has joined. The Iterator will contain Strings where each String represents a room (e.g. room@muc.jabber.org). Note: In order to get a list of bookmarked (but not necessarily joined) conferences, useBookmarkManager.getBookmarkedConferences()
.- Returns:
- a List of the rooms where the user has joined using a given connection.
-
getJoinedRooms
public List<EntityBareJid> getJoinedRooms(EntityFullJid user) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Returns a List of the rooms where the requested user has joined. The Iterator will contain Strings where each String represents a room (e.g. room@muc.jabber.org).- Parameters:
user
- the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.- Returns:
- a List of the rooms where the requested user has joined.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getRoomInfo
public RoomInfo getRoomInfo(EntityBareJid room) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Returns the discovered information of a given room without actually having to join the room. The server will provide information only for rooms that are public.- Parameters:
room
- the name of the room in the form "roomName@service" of which we want to discover its information.- Returns:
- the discovered information of a given room without actually having to join the room.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
getMucServiceDomains
public List<DomainBareJid> getMucServiceDomains() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedExceptionReturns a collection with the XMPP addresses of the Multi-User Chat services.- Returns:
- a collection with the XMPP addresses of the Multi-User Chat services.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
providesMucService
public boolean providesMucService(DomainBareJid domainBareJid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException Check if the provided domain bare JID provides a MUC service.- Parameters:
domainBareJid
- the domain bare JID to check.- Returns:
true
if the provided JID provides a MUC service,false
otherwise.- Throws:
SmackException.NoResponseException
- if there was no response from the remote entity.XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.- Since:
- 4.2
- See Also:
-
getRoomsHostedBy
public Map<EntityBareJid,HostedRoom> getRoomsHostedBy(DomainBareJid serviceName) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.NotAMucServiceException Returns a Map of HostedRooms where each HostedRoom has the XMPP address of the room and the room's name. Once discovered the rooms hosted by a chat service it is possible to discover more detailed room information or join the room.- Parameters:
serviceName
- the service that is hosting the rooms to discover.- Returns:
- a map from the room's address to its HostedRoom information.
- Throws:
XMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NoResponseException
- if there was no response from the remote entity.SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.MultiUserChatException.NotAMucServiceException
- if the entity is not a MUC service.- Since:
- 4.3.1
-
decline
public void decline(EntityBareJid room, EntityBareJid inviter, String reason) throws SmackException.NotConnectedException, InterruptedException Informs the sender of an invitation that the invitee declines the invitation. The rejection will be sent to the room which in turn will forward the rejection to the inviter.- Parameters:
room
- the room that sent the original invitation.inviter
- the inviter of the declined invitation.reason
- the reason why the invitee is declining the invitation.- Throws:
SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
addInvitationListener
Adds a listener to invitation notifications. The listener will be fired anytime an invitation is received.- Parameters:
listener
- an invitation listener.
-
removeInvitationListener
Removes a listener to invitation notifications. The listener will be fired anytime an invitation is received.- Parameters:
listener
- an invitation listener.
-
setAutoJoinOnReconnect
If automatic join on reconnect is enabled, then the manager will try to auto join MUC rooms after the connection got re-established.- Parameters:
autoJoin
-true
to enable,false
to disable.
-
setAutoJoinFailedCallback
Set a callback invoked by this manager when automatic join on reconnect failed. If failedCallback is notnull
, then automatic rejoin get also enabled.- Parameters:
failedCallback
- the callback.
-
setAutoJoinSuccessCallback
Set a callback invoked by this manager when automatic join on reconnect success. If successCallback is notnull
, automatic rejoin will also be enabled.- Parameters:
successCallback
- the callback
-