public class MultiUserChat extends Object
MultiUserChatManager.getMultiUserChat(EntityBareJid)
.
A MultiUserChat is a conversation that takes place among many users in a virtual room. A room could have many occupants with different affiliation and roles. Possible affiliations are "owner", "admin", "member", and "outcast". Possible roles are "moderator", "participant", and "visitor". Each role and affiliation guarantees different privileges (e.g. Send messages to all occupants, Kick participants and visitors, Grant voice, Edit member list, etc.).
Note: Make sure to leave the MUC (leave()
) when you don't need it anymore or
otherwise you may leak the instance.
Modifier and Type | Class and Description |
---|---|
class |
MultiUserChat.MucCreateConfigFormHandle
A handle used to configure a newly created room.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addInvitationRejectionListener(InvitationRejectionListener listener)
Adds a listener to invitation rejections notifications.
|
boolean |
addMessageListener(MessageListener listener)
Adds a stanza listener that will be notified of any new messages in the
group chat.
|
boolean |
addParticipantListener(PresenceListener listener)
Adds a stanza listener that will be notified of any new Presence packets
sent to the group chat.
|
boolean |
addParticipantStatusListener(ParticipantStatusListener listener)
Adds a listener that will be notified of changes in occupants status in the room
such as the user being kicked, banned, or granted admin permissions.
|
void |
addPresenceInterceptor(PresenceListener presenceInterceptor)
Adds a new
StanzaListener that will be invoked every time a new presence
is going to be sent by this MultiUserChat to the server. |
boolean |
addSubjectUpdatedListener(SubjectUpdatedListener listener)
Adds a listener to subject change notifications.
|
boolean |
addUserStatusListener(UserStatusListener listener)
Adds a listener that will be notified of changes in your status in the room
such as the user being kicked, banned, or granted admin permissions.
|
void |
banUser(org.jxmpp.jid.Jid jid,
String reason)
Bans a user from the room.
|
void |
banUsers(Collection<? extends org.jxmpp.jid.Jid> jids)
Bans users from the room.
|
void |
changeAvailabilityStatus(String status,
Presence.Mode mode)
Changes the occupant's availability status within the room.
|
void |
changeNickname(org.jxmpp.jid.parts.Resourcepart nickname)
Changes the occupant's nickname to a new nickname within the room.
|
void |
changeSubject(String subject)
Changes the subject within the room.
|
MultiUserChat.MucCreateConfigFormHandle |
create(org.jxmpp.jid.parts.Resourcepart nickname)
Creates the room according to some default configuration, assign the requesting user as the
room owner, and add the owner to the room but not allow anyone else to enter the room
(effectively "locking" the room).
|
Message |
createMessage()
Creates a new Message to send to the chat room.
|
MultiUserChat.MucCreateConfigFormHandle |
createOrJoin(MucEnterConfiguration mucEnterConfiguration)
Like
create(Resourcepart) , but will return a MultiUserChat.MucCreateConfigFormHandle if the room creation was acknowledged by
the service (with an 201 status code). |
MultiUserChat.MucCreateConfigFormHandle |
createOrJoin(org.jxmpp.jid.parts.Resourcepart nickname)
Create or join the MUC room with the given nickname.
|
MultiUserChat.MucCreateConfigFormHandle |
createOrJoin(org.jxmpp.jid.parts.Resourcepart nickname,
String password,
DiscussionHistory history,
long timeout)
Deprecated.
use
createOrJoin(MucEnterConfiguration) instead. |
MultiUserChat.MucCreateConfigFormHandle |
createOrJoinIfNecessary(org.jxmpp.jid.parts.Resourcepart nickname,
String password)
Create or join a MUC if it is necessary, i.e.
|
Chat |
createPrivateChat(org.jxmpp.jid.EntityFullJid occupant,
ChatMessageListener listener)
Returns a new Chat for sending private messages to a given room occupant.
|
void |
destroy(String reason,
org.jxmpp.jid.EntityBareJid alternateJID)
Sends a request to the server to destroy the room.
|
List<Affiliate> |
getAdmins()
Returns a list of
Affiliate with the room administrators. |
MucConfigFormManager |
getConfigFormManager()
Get a
MucConfigFormManager to configure this room. |
Form |
getConfigurationForm()
Returns the room's configuration form that the room's owner can use or null if
no configuration is possible.
|
MucEnterConfiguration.Builder |
getEnterConfigurationBuilder(org.jxmpp.jid.parts.Resourcepart nickname)
Get a new MUC enter configuration builder.
|
List<Affiliate> |
getMembers()
Returns a list of
Affiliate with the room members. |
List<Occupant> |
getModerators()
Returns a list of
Occupant with the room moderators. |
org.jxmpp.jid.parts.Resourcepart |
getNickname()
Returns the nickname that was used to join the room, or null if not
currently joined.
|
Occupant |
getOccupant(org.jxmpp.jid.EntityFullJid user)
Returns the Occupant information for a particular occupant, or null if the
user is not in the room.
|
Presence |
getOccupantPresence(org.jxmpp.jid.EntityFullJid user)
Returns the presence info for a particular user, or null if the user
is not in the room.
|
List<org.jxmpp.jid.EntityFullJid> |
getOccupants()
Returns an List for the list of fully qualified occupants
in the group chat.
|
int |
getOccupantsCount()
Returns the number of occupants in the group chat.
|
List<Affiliate> |
getOutcasts()
Returns a list of
Affiliate with the room outcasts. |
List<Affiliate> |
getOwners()
Returns a list of
Affiliate with the room owners. |
List<Occupant> |
getParticipants()
Returns a list of
Occupant with the room participants. |
Form |
getRegistrationForm()
Returns the room's registration form that an unaffiliated user, can use to become a member
of the room or null if no registration is possible.
|
String |
getReservedNickname()
Returns the reserved room nickname for the user in the room.
|
org.jxmpp.jid.EntityBareJid |
getRoom()
Returns the name of the room this MultiUserChat object represents.
|
String |
getSubject()
Returns the last known room's subject or null if the user hasn't joined the room
or the room does not have a subject yet.
|
XMPPConnection |
getXmppConnection()
Get the XMPP connection associated with this chat instance.
|
void |
grantAdmin(Collection<? extends org.jxmpp.jid.Jid> jids)
Grants administrator privileges to other users.
|
void |
grantAdmin(org.jxmpp.jid.Jid jid)
Grants administrator privileges to another user.
|
void |
grantMembership(Collection<? extends org.jxmpp.jid.Jid> jids)
Grants membership to other users.
|
void |
grantMembership(org.jxmpp.jid.Jid jid)
Grants membership to a user.
|
void |
grantModerator(Collection<org.jxmpp.jid.parts.Resourcepart> nicknames)
Grants moderator privileges to participants or visitors.
|
void |
grantModerator(org.jxmpp.jid.parts.Resourcepart nickname)
Grants moderator privileges to a participant or visitor.
|
void |
grantOwnership(Collection<? extends org.jxmpp.jid.Jid> jids)
Grants ownership privileges to other users.
|
void |
grantOwnership(org.jxmpp.jid.Jid jid)
Grants ownership privileges to another user.
|
void |
grantVoice(Collection<org.jxmpp.jid.parts.Resourcepart> nicknames)
Grants voice to visitors in the room.
|
void |
grantVoice(org.jxmpp.jid.parts.Resourcepart nickname)
Grants voice to a visitor in the room.
|
void |
invite(org.jxmpp.jid.EntityBareJid user,
String reason)
Invites another user to the room in which one is an occupant.
|
void |
invite(Message message,
org.jxmpp.jid.EntityBareJid user,
String reason)
Invites another user to the room in which one is an occupant using a given Message.
|
boolean |
isJoined()
Returns true if currently in the multi user chat (after calling the
join(Resourcepart) method). |
void |
join(MucEnterConfiguration mucEnterConfiguration)
Joins the chat room using the specified nickname and password.
|
void |
join(org.jxmpp.jid.parts.Resourcepart nickname)
Joins the chat room using the specified nickname.
|
void |
join(org.jxmpp.jid.parts.Resourcepart nickname,
String password)
Joins the chat room using the specified nickname and password.
|
void |
join(org.jxmpp.jid.parts.Resourcepart nickname,
String password,
DiscussionHistory history,
long timeout)
Deprecated.
use
join(MucEnterConfiguration) instead. |
void |
kickParticipant(org.jxmpp.jid.parts.Resourcepart nickname,
String reason)
Kicks a visitor or participant from the room.
|
void |
leave()
Leave the chat room.
|
Presence |
leaveSync()
Leave the chat room.
|
Message |
nextMessage()
Returns the next available message in the chat.
|
Message |
nextMessage(long timeout)
Returns the next available message in the chat.
|
Message |
pollMessage()
Polls for and returns the next message, or null if there isn't
a message immediately available.
|
boolean |
removeInvitationRejectionListener(InvitationRejectionListener listener)
Removes a listener from invitation rejections notifications.
|
boolean |
removeMessageListener(MessageListener listener)
Removes a stanza listener that was being notified of any new messages in the
multi user chat.
|
boolean |
removeParticipantListener(PresenceListener listener)
Removes a stanza listener that was being notified of any new Presence packets
sent to the group chat.
|
boolean |
removeParticipantStatusListener(ParticipantStatusListener listener)
Removes a listener that was being notified of changes in occupants status in the room
such as the user being kicked, banned, or granted admin permissions.
|
void |
removePresenceInterceptor(PresenceListener presenceInterceptor)
Removes a
StanzaListener that was being invoked every time a new presence
was being sent by this MultiUserChat to the server. |
boolean |
removeSubjectUpdatedListener(SubjectUpdatedListener listener)
Removes a listener from subject change notifications.
|
boolean |
removeUserStatusListener(UserStatusListener listener)
Removes a listener that was being notified of changes in your status in the room
such as the user being kicked, banned, or granted admin permissions.
|
void |
requestVoice()
Sends a voice request to the MUC.
|
void |
revokeAdmin(Collection<? extends org.jxmpp.jid.Jid> jids)
Revokes administrator privileges from users.
|
void |
revokeAdmin(org.jxmpp.jid.EntityJid jid)
Revokes administrator privileges from a user.
|
void |
revokeMembership(Collection<? extends org.jxmpp.jid.Jid> jids)
Revokes users' membership.
|
void |
revokeMembership(org.jxmpp.jid.Jid jid)
Revokes a user's membership.
|
void |
revokeModerator(Collection<org.jxmpp.jid.parts.Resourcepart> nicknames)
Revokes moderator privileges from other users.
|
void |
revokeModerator(org.jxmpp.jid.parts.Resourcepart nickname)
Revokes moderator privileges from another user.
|
void |
revokeOwnership(Collection<? extends org.jxmpp.jid.Jid> jids)
Revokes ownership privileges from other users.
|
void |
revokeOwnership(org.jxmpp.jid.Jid jid)
Revokes ownership privileges from another user.
|
void |
revokeVoice(Collection<org.jxmpp.jid.parts.Resourcepart> nicknames)
Revokes voice from participants in the room.
|
void |
revokeVoice(org.jxmpp.jid.parts.Resourcepart nickname)
Revokes voice from a participant in the room.
|
void |
sendConfigurationForm(Form form)
Sends the completed configuration form to the server.
|
void |
sendMessage(Message message)
Sends a Message to the chat room.
|
void |
sendMessage(String text)
Sends a message to the chat room.
|
void |
sendRegistrationForm(Form form)
Sends the completed registration form to the server.
|
String |
toString() |
public org.jxmpp.jid.EntityBareJid getRoom()
public MucEnterConfiguration.Builder getEnterConfigurationBuilder(org.jxmpp.jid.parts.Resourcepart nickname)
nickname
- the nickname used when entering the MUC room.public MultiUserChat.MucCreateConfigFormHandle create(org.jxmpp.jid.parts.Resourcepart nickname) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException, MultiUserChatException.MucAlreadyJoinedException, SmackException.NotConnectedException, MultiUserChatException.MissingMucCreationAcknowledgeException, MultiUserChatException.NotAMucServiceException
To create an "Instant Room", that means a room with some default configuration that is
available for immediate access, the room's owner should send an empty form after creating the
room. Simply call MultiUserChat.MucCreateConfigFormHandle.makeInstant()
on the returned MultiUserChat.MucCreateConfigFormHandle
.
To create a "Reserved Room", that means a room manually configured by the room creator before
anyone is allowed to enter, the room's owner should complete and send a form after creating
the room. Once the completed configuration form is sent to the server, the server will unlock
the room. You can use the returned MultiUserChat.MucCreateConfigFormHandle
to configure the room.
nickname
- the nickname to use.XMPPException.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)SmackException.NoResponseException
- if there was no response from the server.InterruptedException
SmackException.NotConnectedException
MultiUserChatException.MucAlreadyJoinedException
MultiUserChatException.MissingMucCreationAcknowledgeException
MultiUserChatException.NotAMucServiceException
public MultiUserChat.MucCreateConfigFormHandle createOrJoin(org.jxmpp.jid.parts.Resourcepart nickname) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException, MultiUserChatException.MucAlreadyJoinedException, SmackException.NotConnectedException, MultiUserChatException.NotAMucServiceException
nickname
- the nickname to use in the MUC room.MultiUserChat.MucCreateConfigFormHandle
if the room was created while joining, or null
if the room was just joined.SmackException.NoResponseException
XMPPException.XMPPErrorException
InterruptedException
SmackException.NotConnectedException
MultiUserChatException.MucAlreadyJoinedException
MultiUserChatException.NotAMucServiceException
@Deprecated public MultiUserChat.MucCreateConfigFormHandle createOrJoin(org.jxmpp.jid.parts.Resourcepart nickname, String password, DiscussionHistory history, long timeout) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException, MultiUserChatException.MucAlreadyJoinedException, SmackException.NotConnectedException, MultiUserChatException.NotAMucServiceException
createOrJoin(MucEnterConfiguration)
instead.create(Resourcepart)
, 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
value, if he needs to continue sending the room configuration. If false is returned, the room
already existed and the user is able to join right away, without sending a form.nickname
- the nickname to use.password
- the password to use.history
- the amount of discussion history to receive while joining a room.timeout
- the amount of time to wait for a reply from the MUC service(in milliseconds).MultiUserChat.MucCreateConfigFormHandle
if the room was created while joining, or null
if the room was just joined.XMPPException.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)SmackException.NoResponseException
- if there was no response from the server.InterruptedException
MultiUserChatException.MucAlreadyJoinedException
- if the MUC is already joinedSmackException.NotConnectedException
MultiUserChatException.NotAMucServiceException
public MultiUserChat.MucCreateConfigFormHandle createOrJoin(MucEnterConfiguration mucEnterConfiguration) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, InterruptedException, MultiUserChatException.MucAlreadyJoinedException, SmackException.NotConnectedException, MultiUserChatException.NotAMucServiceException
create(Resourcepart)
, but will return a MultiUserChat.MucCreateConfigFormHandle
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
value, if he needs to continue sending the room configuration. If null
is returned, the room
already existed and the user is able to join right away, without sending a form.mucEnterConfiguration
- the configuration used to enter the MUC.MultiUserChat.MucCreateConfigFormHandle
if the room was created while joining, or null
if the room was just joined.XMPPException.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)SmackException.NoResponseException
- if there was no response from the server.InterruptedException
MultiUserChatException.MucAlreadyJoinedException
- if the MUC is already joinedSmackException.NotConnectedException
MultiUserChatException.NotAMucServiceException
public MultiUserChat.MucCreateConfigFormHandle createOrJoinIfNecessary(org.jxmpp.jid.parts.Resourcepart nickname, String password) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.NotAMucServiceException
nickname
- the required nickname to use.password
- the optional password required to joinMultiUserChat.MucCreateConfigFormHandle
if the room was created while joining, or null
if the room was just joined.SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
InterruptedException
MultiUserChatException.NotAMucServiceException
public void join(org.jxmpp.jid.parts.Resourcepart nickname) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.NotAMucServiceException
nickname
- the nickname to use.SmackException.NoResponseException
XMPPException.XMPPErrorException
- if an error occurs joining the room. In particular, a
401 error can occur if no password was provided and one is required; or a
403 error can occur if the user is banned; or a
404 error can occur if the room does not exist or is locked; or a
407 error can occur if user is not on the member list; or a
409 error can occur if someone is already in the group chat with the same nickname.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
MultiUserChatException.NotAMucServiceException
public void join(org.jxmpp.jid.parts.Resourcepart nickname, String password) throws XMPPException.XMPPErrorException, InterruptedException, SmackException.NoResponseException, SmackException.NotConnectedException, MultiUserChatException.NotAMucServiceException
A password is required when joining password protected rooms. If the room does not require a password there is no need to provide one.
nickname
- the nickname to use.password
- the password to use.XMPPException.XMPPErrorException
- if an error occurs joining the room. In particular, a
401 error can occur if no password was provided and one is required; or a
403 error can occur if the user is banned; or a
404 error can occur if the room does not exist or is locked; or a
407 error can occur if user is not on the member list; or a
409 error can occur if someone is already in the group chat with the same nickname.InterruptedException
SmackException.NotConnectedException
SmackException.NoResponseException
- if there was no response from the server.MultiUserChatException.NotAMucServiceException
@Deprecated public void join(org.jxmpp.jid.parts.Resourcepart nickname, String password, DiscussionHistory history, long timeout) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.NotAMucServiceException
join(MucEnterConfiguration)
instead.To control the amount of history to receive while joining a room you will need to provide a configured DiscussionHistory object.
A password is required when joining password protected rooms. If the room does not require a password there is no need to provide one.
If the room does not already exist when the user seeks to enter it, the server will decide to create a new room or not.
nickname
- the nickname to use.password
- the password to use.history
- the amount of discussion history to receive while joining a room.timeout
- the amount of time to wait for a reply from the MUC service(in milleseconds).XMPPException.XMPPErrorException
- if an error occurs joining the room. In particular, a
401 error can occur if no password was provided and one is required; or a
403 error can occur if the user is banned; or a
404 error can occur if the room does not exist or is locked; or a
407 error can occur if user is not on the member list; or a
409 error can occur if someone is already in the group chat with the same nickname.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
MultiUserChatException.NotAMucServiceException
public void join(MucEnterConfiguration mucEnterConfiguration) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.NotAMucServiceException
To control the amount of history to receive while joining a room you will need to provide a configured DiscussionHistory object.
A password is required when joining password protected rooms. If the room does not require a password there is no need to provide one.
If the room does not already exist when the user seeks to enter it, the server will decide to create a new room or not.
mucEnterConfiguration
- the configuration used to enter the MUC.XMPPException.XMPPErrorException
- if an error occurs joining the room. In particular, a
401 error can occur if no password was provided and one is required; or a
403 error can occur if the user is banned; or a
404 error can occur if the room does not exist or is locked; or a
407 error can occur if user is not on the member list; or a
409 error can occur if someone is already in the group chat with the same nickname.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
MultiUserChatException.NotAMucServiceException
public boolean isJoined()
join(Resourcepart)
method).public void leave() throws SmackException.NotConnectedException, InterruptedException
public Presence leaveSync() throws SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, XMPPException.XMPPErrorException, MultiUserChatException.MucNotJoinedException
SmackException.NotConnectedException
InterruptedException
XMPPException.XMPPErrorException
SmackException.NoResponseException
MultiUserChatException.MucNotJoinedException
public MucConfigFormManager getConfigFormManager() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
MucConfigFormManager
to configure this room.
Only room owners are able to configure a room.
SmackException.NoResponseException
XMPPException.XMPPErrorException
SmackException.NotConnectedException
InterruptedException
public Form getConfigurationForm() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
XMPPException.XMPPErrorException
- if an error occurs asking the configuration form for the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void sendConfigurationForm(Form form) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
form
- the form with the new settings.XMPPException.XMPPErrorException
- if an error occurs setting the new rooms' configuration.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public Form getRegistrationForm() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
If the user requesting registration requirements is not allowed to register with the room (e.g. because that privilege has been restricted), the room will return a "Not Allowed" error to the user (error code 405).
XMPPException.XMPPErrorException
- if an error occurs asking the registration form for the room or a
405 error if the user is not allowed to register with the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void sendRegistrationForm(Form form) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
If the desired room nickname is already reserved for that room, the room will return a "Conflict" error to the user (error code 409). If the room does not support registration, it will return a "Service Unavailable" error to the user (error code 503).
form
- the completed registration form.XMPPException.XMPPErrorException
- if an error occurs submitting the registration form. In particular, a
409 error can occur if the desired room nickname is already reserved for that room;
or a 503 error can occur if the room does not support registration.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void destroy(String reason, org.jxmpp.jid.EntityBareJid alternateJID) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
reason
- the reason for the room destruction.alternateJID
- the JID of an alternate location.XMPPException.XMPPErrorException
- if an error occurs while trying to destroy the room.
An error can occur which will be wrapped by an XMPPException --
XMPP error code 403. The error code can be used to present more
appropiate error messages to end-users.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void invite(org.jxmpp.jid.EntityBareJid user, String reason) throws SmackException.NotConnectedException, InterruptedException
If the room is password-protected, the invitee will receive a password to use to join the room. If the room is members-only, the the invitee may be added to the member list.
user
- the user to invite to the room.(e.g. hecate@shakespeare.lit)reason
- the reason why the user is being invited.SmackException.NotConnectedException
InterruptedException
public void invite(Message message, org.jxmpp.jid.EntityBareJid user, String reason) throws SmackException.NotConnectedException, InterruptedException
If the room is password-protected, the invitee will receive a password to use to join the room. If the room is members-only, the the invitee may be added to the member list.
message
- the message to use for sending the invitation.user
- the user to invite to the room.(e.g. hecate@shakespeare.lit)reason
- the reason why the user is being invited.SmackException.NotConnectedException
InterruptedException
public boolean addInvitationRejectionListener(InvitationRejectionListener listener)
listener
- an invitation rejection listener.public boolean removeInvitationRejectionListener(InvitationRejectionListener listener)
listener
- an invitation rejection listener.public boolean addSubjectUpdatedListener(SubjectUpdatedListener listener)
listener
- a subject updated listener.public boolean removeSubjectUpdatedListener(SubjectUpdatedListener listener)
listener
- a subject updated listener.public void addPresenceInterceptor(PresenceListener presenceInterceptor)
StanzaListener
that will be invoked every time a new presence
is going to be sent by this MultiUserChat to the server. Stanza interceptors may
add new extensions to the presence that is going to be sent to the MUC service.presenceInterceptor
- the new stanza interceptor that will intercept presence packets.public void removePresenceInterceptor(PresenceListener presenceInterceptor)
StanzaListener
that was being invoked every time a new presence
was being sent by this MultiUserChat to the server. Stanza interceptors may
add new extensions to the presence that is going to be sent to the MUC service.presenceInterceptor
- the stanza interceptor to remove.public String getSubject()
To be notified every time the room's subject change you should add a listener
to this room. addSubjectUpdatedListener(SubjectUpdatedListener)
To change the room's subject use changeSubject(String)
.
public String getReservedNickname() throws SmackException, InterruptedException
SmackException
- if there was no response from the server.InterruptedException
public org.jxmpp.jid.parts.Resourcepart getNickname()
public void changeNickname(org.jxmpp.jid.parts.Resourcepart nickname) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, MultiUserChatException.MucNotJoinedException
nickname
- the new nickname within the room.XMPPException.XMPPErrorException
- if the new nickname is already in use by another occupant.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
MultiUserChatException.MucNotJoinedException
public void changeAvailabilityStatus(String status, Presence.Mode mode) throws SmackException.NotConnectedException, InterruptedException, MultiUserChatException.MucNotJoinedException
status
- a text message describing the presence update.mode
- the mode type for the presence update.SmackException.NotConnectedException
InterruptedException
MultiUserChatException.MucNotJoinedException
public void kickParticipant(org.jxmpp.jid.parts.Resourcepart nickname, String reason) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
nickname
- the nickname of the participant or visitor to kick from the room
(e.g. "john").reason
- the reason why the participant or visitor is being kicked from the room.XMPPException.XMPPErrorException
- if an error occurs kicking the occupant. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was intended to be kicked (i.e. Not Allowed error); or a
403 error can occur if the occupant that intended to kick another occupant does
not have kicking privileges (i.e. Forbidden error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void requestVoice() throws SmackException.NotConnectedException, InterruptedException
SmackException.NotConnectedException
InterruptedException
public void grantVoice(Collection<org.jxmpp.jid.parts.Resourcepart> nicknames) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
nicknames
- the nicknames of the visitors to grant voice in the room (e.g. "john").XMPPException.XMPPErrorException
- if an error occurs granting voice to a visitor. In particular, a
403 error can occur if the occupant that intended to grant voice is not
a moderator in this room (i.e. Forbidden error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void grantVoice(org.jxmpp.jid.parts.Resourcepart nickname) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
nickname
- the nickname of the visitor to grant voice in the room (e.g. "john").XMPPException.XMPPErrorException
- if an error occurs granting voice to a visitor. In particular, a
403 error can occur if the occupant that intended to grant voice is not
a moderator in this room (i.e. Forbidden error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeVoice(Collection<org.jxmpp.jid.parts.Resourcepart> nicknames) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
nicknames
- the nicknames of the participants to revoke voice (e.g. "john").XMPPException.XMPPErrorException
- if an error occurs revoking voice from a participant. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was tried to revoke his voice (i.e. Not Allowed error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeVoice(org.jxmpp.jid.parts.Resourcepart nickname) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
nickname
- the nickname of the participant to revoke voice (e.g. "john").XMPPException.XMPPErrorException
- if an error occurs revoking voice from a participant. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was tried to revoke his voice (i.e. Not Allowed error); or a
400 error can occur if the provided nickname is not present in the room.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void banUsers(Collection<? extends org.jxmpp.jid.Jid> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jids
- the bare XMPP user IDs of the users to ban.XMPPException.XMPPErrorException
- if an error occurs banning a user. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was tried to be banned (i.e. Not Allowed error).SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void banUser(org.jxmpp.jid.Jid jid, String reason) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jid
- the bare XMPP user ID of the user to ban (e.g. "user@host.org").reason
- the optional reason why the user was banned.XMPPException.XMPPErrorException
- if an error occurs banning a user. In particular, a
405 error can occur if a moderator or a user with an affiliation of "owner" or "admin"
was tried to be banned (i.e. Not Allowed error).SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void grantMembership(Collection<? extends org.jxmpp.jid.Jid> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jids
- the XMPP user IDs of the users to grant membership.XMPPException.XMPPErrorException
- if an error occurs granting membership to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void grantMembership(org.jxmpp.jid.Jid jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jid
- the XMPP user ID of the user to grant membership (e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs granting membership to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeMembership(Collection<? extends org.jxmpp.jid.Jid> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jids
- the bare XMPP user IDs of the users to revoke membership.XMPPException.XMPPErrorException
- if an error occurs revoking membership to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeMembership(org.jxmpp.jid.Jid jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jid
- the bare XMPP user ID of the user to revoke membership (e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs revoking membership to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void grantModerator(Collection<org.jxmpp.jid.parts.Resourcepart> nicknames) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
nicknames
- the nicknames of the occupants to grant moderator privileges.XMPPException.XMPPErrorException
- if an error occurs granting moderator privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void grantModerator(org.jxmpp.jid.parts.Resourcepart nickname) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
nickname
- the nickname of the occupant to grant moderator privileges.XMPPException.XMPPErrorException
- if an error occurs granting moderator privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeModerator(Collection<org.jxmpp.jid.parts.Resourcepart> nicknames) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
nicknames
- the nicknames of the occupants to revoke moderator privileges.XMPPException.XMPPErrorException
- if an error occurs revoking moderator privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeModerator(org.jxmpp.jid.parts.Resourcepart nickname) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
nickname
- the nickname of the occupant to revoke moderator privileges.XMPPException.XMPPErrorException
- if an error occurs revoking moderator privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void grantOwnership(Collection<? extends org.jxmpp.jid.Jid> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jids
- the collection of bare XMPP user IDs of the users to grant ownership.XMPPException.XMPPErrorException
- if an error occurs granting ownership privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void grantOwnership(org.jxmpp.jid.Jid jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jid
- the bare XMPP user ID of the user to grant ownership (e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs granting ownership privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeOwnership(Collection<? extends org.jxmpp.jid.Jid> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jids
- the bare XMPP user IDs of the users to revoke ownership.XMPPException.XMPPErrorException
- if an error occurs revoking ownership privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeOwnership(org.jxmpp.jid.Jid jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jid
- the bare XMPP user ID of the user to revoke ownership (e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs revoking ownership privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void grantAdmin(Collection<? extends org.jxmpp.jid.Jid> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jids
- the bare XMPP user IDs of the users to grant administrator privileges.XMPPException.XMPPErrorException
- if an error occurs granting administrator privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void grantAdmin(org.jxmpp.jid.Jid jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jid
- the bare XMPP user ID of the user to grant administrator privileges
(e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs granting administrator privileges to a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeAdmin(Collection<? extends org.jxmpp.jid.Jid> jids) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jids
- the bare XMPP user IDs of the user to revoke administrator privileges.XMPPException.XMPPErrorException
- if an error occurs revoking administrator privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void revokeAdmin(org.jxmpp.jid.EntityJid jid) throws XMPPException.XMPPErrorException, SmackException.NoResponseException, SmackException.NotConnectedException, InterruptedException
jid
- the bare XMPP user ID of the user to revoke administrator privileges
(e.g. "user@host.org").XMPPException.XMPPErrorException
- if an error occurs revoking administrator privileges from a user.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public int getOccupantsCount()
Note: this value will only be accurate after joining the group chat, and may fluctuate over time. If you query this value directly after joining the group chat it may not be accurate, as it takes a certain amount of time for the server to send all presence packets to this client.
public List<org.jxmpp.jid.EntityFullJid> getOccupants()
XmppStringUtils.parseResource(String)
method.
Note: this value will only be accurate after joining the group chat, and may
fluctuate over time.public Presence getOccupantPresence(org.jxmpp.jid.EntityFullJid user)
user
- the room occupant to search for his presence. The format of user must
be: roomName@service/nickname (e.g. darkcave@macbeth.shakespeare.lit/thirdwitch).public Occupant getOccupant(org.jxmpp.jid.EntityFullJid user)
user
- the room occupant to search for his presence. The format of user must
be: roomName@service/nickname (e.g. darkcave@macbeth.shakespeare.lit/thirdwitch).public boolean addParticipantListener(PresenceListener listener)
listener
- a stanza listener that will be notified of any presence packets
sent to the group chat.public boolean removeParticipantListener(PresenceListener listener)
listener
- a stanza listener that was being notified of any presence packets
sent to the group chat.public List<Affiliate> getOwners() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Affiliate
with the room owners.Affiliate
with the room owners.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public List<Affiliate> getAdmins() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Affiliate
with the room administrators.Affiliate
with the room administrators.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public List<Affiliate> getMembers() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Affiliate
with the room members.Affiliate
with the room members.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public List<Affiliate> getOutcasts() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Affiliate
with the room outcasts.Affiliate
with the room outcasts.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public List<Occupant> getModerators() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Occupant
with the room moderators.Occupant
with the room moderators.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public List<Occupant> getParticipants() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
Occupant
with the room participants.Occupant
with the room participants.XMPPException.XMPPErrorException
- if you don't have enough privileges to get this information.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public void sendMessage(String text) throws SmackException.NotConnectedException, InterruptedException
text
- the text of the message to send.SmackException.NotConnectedException
InterruptedException
public Chat createPrivateChat(org.jxmpp.jid.EntityFullJid occupant, ChatMessageListener listener)
occupant
- occupant unique room JID (e.g. 'darkcave@macbeth.shakespeare.lit/Paul').listener
- the listener is a message listener that will handle messages for the newly
created chat.public Message createMessage()
public void sendMessage(Message message) throws SmackException.NotConnectedException, InterruptedException
message
- the message.SmackException.NotConnectedException
InterruptedException
public Message pollMessage() throws MultiUserChatException.MucNotJoinedException
nextMessage()
method since it's non-blocking.
In other words, the method call will always return immediately, whereas the
nextMessage method will return only when a message is available (or after
a specific timeout).MultiUserChatException.MucNotJoinedException
public Message nextMessage() throws MultiUserChatException.MucNotJoinedException, InterruptedException
MultiUserChatException.MucNotJoinedException
InterruptedException
public Message nextMessage(long timeout) throws MultiUserChatException.MucNotJoinedException, InterruptedException
timeout
- the maximum amount of time to wait for the next message.MultiUserChatException.MucNotJoinedException
InterruptedException
public boolean addMessageListener(MessageListener listener)
listener
- a stanza listener.public boolean removeMessageListener(MessageListener listener)
listener
- a stanza listener.public void changeSubject(String subject) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
subject
- the new room's subject to set.XMPPException.XMPPErrorException
- if someone without appropriate privileges attempts to change the
room subject will throw an error with code 403 (i.e. Forbidden)SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
InterruptedException
public boolean addUserStatusListener(UserStatusListener listener)
listener
- a user status listener.public boolean removeUserStatusListener(UserStatusListener listener)
listener
- a user status listener.public boolean addParticipantStatusListener(ParticipantStatusListener listener)
listener
- a participant status listener.public boolean removeParticipantStatusListener(ParticipantStatusListener listener)
listener
- a participant status listener.public XMPPConnection getXmppConnection()