Package org.jivesoftware.openfire.muc
Class MUCRoom
java.lang.Object
org.jivesoftware.openfire.muc.MUCRoom
- All Implemented Interfaces:
Externalizable
,Serializable
,GroupEventListener
,UserEventListener
,Cacheable
,org.xmpp.resultsetmanagement.Result
public class MUCRoom
extends Object
implements GroupEventListener, UserEventListener, Externalizable, org.xmpp.resultsetmanagement.Result, Cacheable
A chat room on the chat server manages its users, and enforces its own security rules.
A MUCRoom could represent a persistent room which means that its configuration will be maintained in sync with its
representation in the database, or it represents a non-persistent room. These rooms have no representation in the
database.
- Author:
- Gaston Dombiak, Guus der Kinderen, guus@goodbytes.nl
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SystemProperty<Boolean>
static final SystemProperty<Boolean>
boolean
After a room has been destroyed it may remain in memory, but it won't be possible to use it.static final SystemProperty<Boolean>
final ArrayList<MUCOccupant>
All occupants that are associated with this room. -
Constructor Summary
ConstructorsConstructorDescriptionMUCRoom()
Do not use this constructor.MUCRoom
(MultiUserChatService chatService, String roomName) Create a new chat room. -
Method Summary
Modifier and TypeMethodDescriptionList<org.xmpp.packet.Presence>
addAdmin
(org.xmpp.packet.JID targetUserAddress, Affiliation actorAffiliation) Adds a new user to the list of admins.List<org.xmpp.packet.Presence>
addAdmins
(List<org.xmpp.packet.JID> targetUserAddresses, Affiliation actorAffiliation) Adds a list of users to the list of admins.void
addFirstOwner
(org.xmpp.packet.JID targetUserAddress) Adds a new user to the list of owners.List<org.xmpp.packet.Presence>
addMember
(org.xmpp.packet.JID targetUserAddress, String nickname, Affiliation actorAffiliation) Adds a new user to the list of members.List<org.xmpp.packet.Presence>
addModerator
(org.xmpp.packet.JID targetUserAddress, Affiliation actorAffiliation) Changes the role of the user within the room to moderator.List<org.xmpp.packet.Presence>
addNone
(org.xmpp.packet.JID targetUserAddress, Affiliation actorAffiliation) Removes the user from all the other affiliation list thus giving the user a NONE affiliation.void
addOccupant
(MUCOccupant occupant) Adds an occupant to all the internal occupants collections.List<org.xmpp.packet.Presence>
addOutcast
(org.xmpp.packet.JID targetUserAddress, String reason, org.xmpp.packet.JID actorUserAddress, Affiliation actorAffiliation, Role actorRole) Adds a new user to the list of outcast users.List<org.xmpp.packet.Presence>
addOwner
(org.xmpp.packet.JID targetUserAddress, Affiliation actorAffiliation) Adds a new user to the list of owners.List<org.xmpp.packet.Presence>
addOwners
(List<org.xmpp.packet.JID> targetUserAddresses, Affiliation actorAffiliation) Adds a list of users to the list of owners.List<org.xmpp.packet.Presence>
addParticipant
(org.xmpp.packet.JID targetUserAddress, String reason, Affiliation actorAffiliation, Role actorRole) Changes the role of the user within the room to participant.void
addRealJidToMessage
(org.xmpp.packet.Message message, MUCOccupant sender) Based on XEP-0045, section 7.2.13: If the room is non-anonymous, the service MAY include an Extended Stanza Addressing (XEP-0033) [16] element that notes the original full JID of the sender by means of the "ofrom" address typeList<org.xmpp.packet.Presence>
addVisitor
(org.xmpp.packet.JID targetUserAddress, Affiliation actorAffiliation, Role actorRole) Changes the role of the user within the room to visitor.void
adminAdded
(Group group, Map<String, ?> params) An administrator was added to a group.void
adminRemoved
(Group group, Map<String, ?> params) An administrator was removed from a group.boolean
alreadyJoinedWithThisNick
(org.xmpp.packet.JID realJID, String nickname) void
broadcast
(org.xmpp.packet.Message message) Broadcasts the message stanza as captured by the argument to all occupants that are local to the domain (in other words, it excludes occupants that connected via FMUC).void
broadcast
(org.xmpp.packet.Presence presence, boolean isJoinPresence) Broadcasts the presence stanza as captured by the argument to all occupants that are local to the local domain (in other words, it excludes occupants that are connected via FMUC).boolean
Returns true if every presence packet will include the JID of every occupant.boolean
canBroadcastPresence
(Role roleToBroadcast) Returns true if the presences of the requested role will be broadcast.boolean
Returns true if room occupants are allowed to change their nicknames in the room.boolean
Returns true if participants are allowed to change the room's subject.boolean
Returns true if occupants can invite other users to the room.Returns the minimal role of persons that are allowed to send private messages in the room.void
changeSubject
(org.xmpp.packet.Message packet, MUCOccupant actor) Changes the room's subject if the occupant has enough permissions.Asynchronously remove the chat history of a room from run-time memory and database storage.org.xmpp.packet.Presence
createPresence
(org.xmpp.packet.Presence.Type presenceType) Create a new presence in this room for the given role.void
destroyRoom
(org.xmpp.packet.JID alternateJID, String reason) Destroys the room.void
destroyRoom
(org.xmpp.packet.JID alternateJID, String password, String reason) Destroys the room.boolean
findNickname
(org.xmpp.packet.JID userAddress) Attempts to find a nickname for a user.generateOccupantId
(org.xmpp.packet.JID userJid) Creates an Occupant ID based on the generation specification defined in XEP-0421.Collection<org.xmpp.packet.JID>
Returns a collection with the current list of admins.getAffiliation
(org.xmpp.packet.JID userAddress) Returns the affiliation state of the user in the room.int
Returns the approximate size of the Object in bytes.long
Returns the total length of the chat session.Returns the date when the room was created.Returns a description set by the room's owners about the room.Returns the date when the last occupant left the room.Set<org.xmpp.packet.JID>
A set of addresses of MUC rooms (typically on a remote XMPP domain) that defines the list of rooms that is permitted to federate with the local room.Returns the 'mode' that describes the FMUC configuration is captured in the supplied object, which is either master-master or master-slave.org.xmpp.packet.JID
Returns the address of the MUC room (typically on a remote XMPP domain) to which this room should initiate FMUC federation.long
getID()
Obtain a unique numerical id for this room.org.xmpp.packet.JID
getJID()
Get the full JID of this room.Returns the date when the room was locked.int
Returns the maximum number of occupants that can be simultaneously in the room.org.xmpp.packet.JID
getMemberForReservedNickname
(String nickname) Returns the bare JID of the member for which a nickname is reserved.Collection<org.xmpp.packet.JID>
Returns a collection with the current list of room members.Returns a collection with the current list of room moderators.Returns the last date when the room's configuration was modified.Get the multi-user chat service the room is attached to.getName()
Get the name of this room.Returns the natural language name of the room.getOccupantByFullJID
(org.xmpp.packet.JID userAddress) Returns the occupant data of a given user in the room by his full JID ornull
if no occupant data was found for the specified user.Obtain the roles of all users in the chatroom.getOccupantsByBareJID
(org.xmpp.packet.JID userAddress) Obtain the roles of a given user in the room by his bare JID.getOccupantsByNickname
(String nickname) Obtain the roles of a given user by nickname.int
Returns the number of occupants in the chatroom at the moment.Collection<org.xmpp.packet.JID>
Returns a collection with the current list of outcast users.Collection<org.xmpp.packet.JID>
Returns a collection with the current list of owners.Returns a collection with the current list of room participants.Returns the password that the user must provide to enter the room.getReservedNickname
(org.xmpp.packet.JID userAddress) Returns the reserved room nickname for the bare JID or null if none.getRole
(org.xmpp.packet.JID userAddress) Returns the list of roles of which presence will be broadcast to the rest of the occupants.Returns the history of the room which includes chat transcripts.Obtain the occupant data representing the chat service itself (mainly for addressing messages and presence).Returns the last subject that some occupant set to the room.getUID()
void
groupCreated
(Group group, Map<String, ?> params) A group was created.void
groupDeleting
(Group group, Map<String, ?> params) A group is being deleted.void
groupModified
(Group group, Map<String, ?> params) A group's name, description, or an extended property was changed.int
hashCode()
boolean
hasOccupant
(String nickname) Determine if a given nickname is taken.boolean
hasOccupant
(org.xmpp.packet.JID jid) boolean
Returns true if this room accepts FMUC joins.boolean
isLocked()
Returns true if the room is locked.boolean
Returns true if the room's conversation is being logged.boolean
Returns true if registered users can only join the room using their registered nickname.boolean
Returns true if the room is locked and it was locked by a room owner after the room was initially configured.boolean
Returns true if the room requires an invitation to enter.boolean
Returns if the room in which only those with "voice" may send messages to all occupants.boolean
Returns true if a user cannot enter without first providing the correct password.boolean
Returns true if the room is not destroyed if the last occupant exits.boolean
Returns true if the room's conversation will be preserved when the room is deleted.boolean
Returns true if the room is searchable and visible through service discovery.boolean
Returns true if users are allowed to register with the room.boolean
Returns whether the room should be retired on deletion.joinRoom
(String nickname, String password, HistoryRequest historyRequest, org.xmpp.packet.JID realAddress, org.xmpp.packet.Presence presence) Joins the room using the given nickname.List<org.xmpp.packet.Presence>
kickOccupant
(org.xmpp.packet.JID userAddress, Affiliation actorAffiliation, Role actorRole, org.xmpp.packet.JID actorJID, String actorNickname, String reason) Kicks a user from the room.List<org.xmpp.packet.Presence>
kickOccupant
(org.xmpp.packet.JID userAddress, Affiliation actorAffiliation, Role actorRole, org.xmpp.packet.JID actorJID, String actorNickname, String reason, int status) Kicks a user from the room.void
leaveRoom
(MUCOccupant leavingOccupant) Remove a member from the chat room.void
lock
(MUCOccupant actor) Locks the room so that users cannot join the room.void
memberAdded
(Group group, Map<String, ?> params) A member was added to a group.void
memberRemoved
(Group group, Map<String, ?> params) A member was removed from a group.void
nicknameChanged
(MUCOccupant occupant, org.xmpp.packet.Presence newPresence, String oldNick, String newNick) An event callback fired whenever an occupant changes his nickname within the chatroom.void
presenceUpdated
(MUCOccupant occupant, org.xmpp.packet.Presence newPresence) An event callback fired whenever an occupant updated his presence in the chatroom.void
void
removeOccupant
(MUCOccupant occupant) Removes the occupant from all the internal occupants collections.void
saveToDB()
Saves the room configuration to the DB.void
send
(org.xmpp.packet.Packet packet, MUCOccupant sender) Sends a packet to the occupants of the room.sendInitialPresenceToExistingOccupants
(MUCOccupant joinedOccupant) Sends presence of new occupant to existing occupants.void
sendInvitation
(org.xmpp.packet.JID to, String reason, Affiliation senderAffiliation, org.xmpp.packet.JID senderUserAddress, List<org.dom4j.Element> extensions) Sends an invitation to a user.void
sendInvitationRejection
(org.xmpp.packet.JID to, String reason, org.xmpp.packet.JID sender) Sends the rejection to the inviter.sendLeavePresenceToExistingOccupants
(MUCOccupant leavingOccupant) Sends presence of a leaving occupant to applicable occupants of the room that is being left.void
sendPrivatePacket
(org.xmpp.packet.Packet packet, MUCOccupant sender) Sends a private packet to a selected occupant.void
sendPublicMessage
(org.xmpp.packet.Message message, MUCOccupant sender) Sends a message to the all the occupants.void
serverBroadcast
(String msg) Broadcast a given message to all members of this chat room.void
setCanAnyoneDiscoverJID
(boolean canAnyoneDiscoverJID) Sets if every presence packet will include the JID of every occupant.void
setCanOccupantsChangeSubject
(boolean canOccupantsChangeSubject) Sets if participants are allowed to change the room's subject.void
setCanOccupantsInvite
(boolean canOccupantsInvite) Sets if occupants can invite other users to the room.void
Sets the minimal role of persons that are allowed to send private messages in the room.void
setChangeNickname
(boolean canChange) Sets if room occupants are allowed to change their nicknames in the room.void
setCreationDate
(Date creationDate) Sets the date when the room was created.void
setDescription
(String description) Sets a description set by the room's owners about the room.void
setEmptyDate
(Date emptyDate) Sets the date when the last occupant left the room.void
setFmucEnabled
(boolean fmucEnabled) Sets if this room accepts FMUC joins.void
setFmucInboundNodes
(Set<org.xmpp.packet.JID> fmucInboundNodes) A set of addresses of MUC rooms (typically on a remote XMPP domain) that defines the list of rooms that is permitted to federate with the local room.void
setFmucOutboundMode
(FMUCMode fmucOutboundMode) Sets the 'mode' that describes the FMUC configuration is captured in the supplied object, which is either master-master or master-slave.void
setFmucOutboundNode
(org.xmpp.packet.JID fmucOutboundNode) Sets the address of the MUC room (typically on a remote XMPP domain) to which this room should initiate FMUC federation.void
setID
(long roomID) Sets a new room ID if the room has just been saved to the database or sets the saved ID of the room in the database while loading the room.void
setLockedDate
(Date lockedTime) Sets the date when the room was locked.void
setLogEnabled
(boolean logEnabled) Sets if the room's conversation is being logged.void
setLoginRestrictedToNickname
(boolean restricted) Sets if registered users can only join the room using their registered nickname.void
setMaxUsers
(int maxUsers) Sets the maximum number of occupants that can be simultaneously in the room.List<org.xmpp.packet.Presence>
setMembersOnly
(boolean membersOnly, Affiliation actorAffiliation, org.xmpp.packet.JID actorJid) Sets if the room requires an invitation to enter.void
setModerated
(boolean moderated) Sets if the room in which only those with "voice" may send messages to all occupants.void
setModificationDate
(Date modificationDate) Sets the last date when the room's configuration was modified.void
setMUCService
(MultiUserChatService service) Sets the multi-user chat service the room is attached to.void
setNaturalLanguageName
(String naturalLanguageName) Sets the natural language name of the room.void
setPassword
(String password) Sets the password that the user must provide to enter the room.void
setPersistent
(boolean persistent) Sets if the room is not destroyed if the last occupant exits.void
setPreserveHistOnRoomDeletionEnabled
(boolean preserveHistOnRoomDeletion) Sets if the room's conversation will be preserved when the room is deleted.void
setPublicRoom
(boolean publicRoom) Sets if the room is searchable and visible through service discovery.void
setRegistrationEnabled
(boolean registrationEnabled) Sets if users are allowed to register with the room.void
setRetireOnDeletion
(boolean retire) Sets whether the room should be retired on deletion.void
setRolesToBroadcastPresence
(List<Role> rolesToBroadcastPresence) Sets the list of roles of which presence will be broadcast to the rest of the occupants.void
setSavedToDB
(boolean saved) Sets if the room has already been made persistent.void
setSubject
(String subject) Sets the last subject that some occupant set to the room.toString()
void
unlock
(Affiliation actorAffiliation) Unlocks the room so that users can join the room.void
updateConfiguration
(MUCRoom otherRoom) void
userCreated
(User user, Map<String, Object> params) A user was created.void
userDeleting
(User user, Map<String, Object> params) A user is being deleted.void
userModified
(User user, Map<String, Object> params) A user's name, email, or an extended property was changed.boolean
Returns true if the room has already been made persistent.void
-
Field Details
-
JOIN_PRESENCE_ENABLE
-
ALLOWPM_BLOCKALL
-
BULK_MSG_RETRACTION_ENABLED
-
occupants
All occupants that are associated with this room. -
isDestroyed
public boolean isDestroyedAfter a room has been destroyed it may remain in memory, but it won't be possible to use it. When a room is destroyed it is immediately removed from the MultiUserChatService, but it's possible that while the room was being destroyed it was being used by another thread, so we need to protect the room under these rare circumstances.
-
-
Constructor Details
-
MUCRoom
public MUCRoom()Do not use this constructor. It was added to implement the Externalizable interface required to work inside a cluster. -
MUCRoom
Create a new chat room.- Parameters:
chatService
- the service hosting the room.roomName
- the name of the room.
-
-
Method Details
-
getName
Get the name of this room.- Returns:
- The name for this room
-
getJID
public org.xmpp.packet.JID getJID()Get the full JID of this room.- Returns:
- the JID for this room.
-
getMUCService
Get the multi-user chat service the room is attached to.- Returns:
- the MultiUserChatService instance that the room is attached to.
-
setMUCService
Sets the multi-user chat service the room is attached to.- Parameters:
service
- The MultiUserChatService that the room is attached to (cannot benull
).
-
getID
public long getID()Obtain a unique numerical id for this room. Useful for storing rooms in databases. If the room is persistent or is logging the conversation then the returned ID won't be -1.- Returns:
- The unique id for this room or -1 if the room is temporary and is not logging the conversation.
-
setID
public void setID(long roomID) Sets a new room ID if the room has just been saved to the database or sets the saved ID of the room in the database while loading the room.- Parameters:
roomID
- the saved ID of the room in the DB or a new one if the room is being saved to the DB.
-
getCreationDate
Returns the date when the room was created.- Returns:
- the date when the room was created.
-
setCreationDate
Sets the date when the room was created.- Parameters:
creationDate
- the date when the room was created (cannot benull
).
-
getModificationDate
Returns the last date when the room's configuration was modified. If the room's configuration was never modified then the creation date will be returned.- Returns:
- the last date when the room's configuration was modified.
-
setModificationDate
Sets the last date when the room's configuration was modified. If the room's configuration was never modified then the initial value will be the same as the creation date.- Parameters:
modificationDate
- the last date when the room's configuration was modified (cannot benull
).
-
setEmptyDate
Sets the date when the last occupant left the room. A null value means that there are occupants in the room at the moment.- Parameters:
emptyDate
- the date when the last occupant left the room or null if there are occupants in the room (can benull
).
-
getEmptyDate
Returns the date when the last occupant left the room. A null value means that there are occupants in the room at the moment.- Returns:
- the date when the last occupant left the room or null if there are occupants in the room at the moment.
-
getSelfRepresentation
Obtain the occupant data representing the chat service itself (mainly for addressing messages and presence).- Returns:
- The representation of the chat room itself
-
getOccupantsByNickname
Obtain the roles of a given user by nickname. A user can be connected to a room more than once.- Parameters:
nickname
- The nickname of the user you'd like to obtain (cannot benull
)- Returns:
- The user's role in the room
- Throws:
UserNotFoundException
- If there is no user with the given nickname
-
getOccupantsByBareJID
public List<MUCOccupant> getOccupantsByBareJID(@Nonnull org.xmpp.packet.JID userAddress) throws UserNotFoundException Obtain the roles of a given user in the room by his bare JID. A user can have several roles, one for each client resource from which the user has joined the room.- Parameters:
userAddress
- The (real) JID of the user you'd like to obtain.- Returns:
- The user's roles in the room
- Throws:
UserNotFoundException
- If there is no user with the given nickname
-
getOccupantByFullJID
Returns the occupant data of a given user in the room by his full JID ornull
if no occupant data was found for the specified user.- Parameters:
userAddress
- The full JID of the user you'd like to obtain.- Returns:
- The user's occupant data in the room or null if not found.
-
getOccupants
Obtain the roles of all users in the chatroom.- Returns:
- a collection with all users in the chatroom
-
getOccupantsCount
public int getOccupantsCount()Returns the number of occupants in the chatroom at the moment.- Returns:
- int the number of occupants in the chatroom at the moment.
-
hasOccupant
Determine if a given nickname is taken.- Parameters:
nickname
- The nickname of the user you'd like to obtain (cannot benull
).- Returns:
- True if a nickname is taken
-
hasOccupant
public boolean hasOccupant(org.xmpp.packet.JID jid) -
findNickname
Attempts to find a nickname for a user. This method will first check if there's an occupant that matches the provided user address. If none is found, then any reserved nickname for the user address is returned. When no nickname can be found, null is returned.- Parameters:
userAddress
- The (real) address for which to return a nickname- Returns:
- a nickname for the user, or null.
-
getReservedNickname
Returns the reserved room nickname for the bare JID or null if none.- Parameters:
userAddress
- The (real) JID of the user of which you'd like to obtain his reserved nickname .- Returns:
- the reserved room nickname for the user, or null if none.
-
getMemberForReservedNickname
Returns the bare JID of the member for which a nickname is reserved. Returns null if no member registered the nickname.- Parameters:
nickname
- The nickname for which to look up a member.- Returns:
- the bare JID of the member that has registered this nickname, or null if none.
-
getAffiliation
Returns the affiliation state of the user in the room. Possible affiliations are MUCOccupant.OWNER, MUCOccupant.ADMINISTRATOR, MUCOccupant.MEMBER, MUCOccupant.OUTCAST and MUCOccupant.NONE. Note: Prerequisite - A lock must already be obtained before sending this message.- Parameters:
userAddress
- The (real) JID of the user of which you'd like to obtain his affiliation.- Returns:
- the affiliation state of the user in the room.
-
getRole
-
joinRoom
public MUCOccupant joinRoom(@Nonnull String nickname, @Nullable String password, @Nullable HistoryRequest historyRequest, @Nonnull org.xmpp.packet.JID realAddress, @Nonnull org.xmpp.packet.Presence presence) throws UnauthorizedException, UserAlreadyExistsException, RoomLockedException, ForbiddenException, RegistrationRequiredException, ConflictException, ServiceUnavailableException, NotAcceptableException Joins the room using the given nickname.- Parameters:
nickname
- The nickname the user wants to use in the chatroom (cannot benull
).password
- The password provided by the user to enter the chatroom or null if none.historyRequest
- The amount of history that the user request or null meaning default.realAddress
- The 'real' (non-room) JID of the user that is joining (cannot benull
).presence
- The presence sent by the user to join the room (cannot benull
).- Returns:
- The occupant data created for the user.
- Throws:
UnauthorizedException
- If the user doesn't have permission to join the room.UserAlreadyExistsException
- If the nickname is already taken.RoomLockedException
- If the user is trying to join a locked room.ForbiddenException
- If the user is an outcast.RegistrationRequiredException
- If the user is not a member of a members-only room.ConflictException
- If another user attempts to join the room with a nickname reserved by the first user.ServiceUnavailableException
- If the user cannot join the room since the max number of users has been reached.NotAcceptableException
- If the registered user is trying to join with a nickname different from the reserved nickname.
-
alreadyJoinedWithThisNick
public boolean alreadyJoinedWithThisNick(@Nonnull org.xmpp.packet.JID realJID, @Nonnull String nickname) -
addOccupant
Adds an occupant to all the internal occupants collections.- Parameters:
occupant
- the occupant to add.
-
sendLeavePresenceToExistingOccupants
Sends presence of a leaving occupant to applicable occupants of the room that is being left.- Parameters:
leavingOccupant
- the occupant that is leaving.
-
leaveRoom
Remove a member from the chat room.- Parameters:
leavingOccupant
- The occupant data that the user that left the room has prior to the user leaving.
-
sendInitialPresenceToExistingOccupants
Sends presence of new occupant to existing occupants.- Parameters:
joinedOccupant
- the occupant data of the new user in the room.
-
removeOccupant
Removes the occupant from all the internal occupants collections. The occupant data will also be removed from the user's occupant-data collection.- Parameters:
occupant
- the occupant to remove.
-
clearChatHistory
Asynchronously remove the chat history of a room from run-time memory and database storage. If bulk message retraction is enabled, it sends message retraction stanzas to all occupants. -
destroyRoom
Destroys the room. Each occupant will be removed and will receive a presence stanza of type "unavailable" whose "from" attribute will be the occupant's nickname that the user knows he or she has been removed from the room.- Parameters:
alternateJID
- an optional alternate JID. Commonly used to provide a replacement room. (can benull
)reason
- an optional reason why the room was destroyed (can benull
).
-
destroyRoom
Destroys the room. Each occupant will be removed and will receive a presence stanza of type "unavailable" whose "from" attribute will be the occupant's nickname that the user knows he or she has been removed from the room.- Parameters:
alternateJID
- an optional alternate JID. Commonly used to provide a replacement room. (can benull
)password
- an optional password to be used for accessing the replacement room (can benull
).reason
- an optional reason why the room was destroyed (can benull
).
-
createPresence
public org.xmpp.packet.Presence createPresence(org.xmpp.packet.Presence.Type presenceType) Create a new presence in this room for the given role.- Parameters:
presenceType
- Type of presence to create (cannot benull
).- Returns:
- The new presence
-
serverBroadcast
Broadcast a given message to all members of this chat room. The sender is always set to be the chatroom.- Parameters:
msg
- The message to broadcast (cannot benull
)
-
sendPublicMessage
public void sendPublicMessage(org.xmpp.packet.Message message, MUCOccupant sender) throws ForbiddenException Sends a message to the all the occupants. In a moderated room, this privilege is restricted to occupants with a role of participant or higher. In an unmoderated room, any occupant can send a message to all other occupants.- Parameters:
message
- The message to send (cannot benull
).sender
- the occupant data of the user that is trying to send a public message (cannot benull
).- Throws:
ForbiddenException
- If the user is not allowed to send a public message (i.e. does not have voice in the room).
-
sendPrivatePacket
public void sendPrivatePacket(@Nonnull org.xmpp.packet.Packet packet, @Nullable MUCOccupant sender) throws NotFoundException, ForbiddenException, NotAcceptableException Sends a private packet to a selected occupant. The packet can be a Message for private conversation between room occupants or IQ packets when an occupant wants to send IQ packets to other room occupants. If the system property xmpp.muc.allowpm.blockall is set to true, this will block all private packets However, if this property is false (by default) then it will allow non-message private packets. If the system property xmpp.muc.vcard.enabled is set to true, then IQ requests that are VCard requests for occupants of the MUC room are processed differently to allow for VCards to be requested from the home server of the occupant. SeeMultiUserChatServiceImpl.processVCardResponse(IQ)
for details.- Parameters:
packet
- The packet to send.sender
- the occupant data of the user that is trying to send a public message.- Throws:
NotFoundException
- If the user is sending a packet to a room JID that does not exist.ForbiddenException
- If a user of this role is not permitted to send private messages in this room.NotAcceptableException
-
send
Sends a packet to the occupants of the room. The second argument defines the sender/originator of the stanza. Typically, this is the same entity that's also the 'subject' of the stanza (eg: someone that changed its presence or nickname). It is important to realize that this needs to be the case. When, for example, an occupant is made a moderator, the 'sender' typically is the entity that granted the role to another entity. It is also possible for the sender to be a reflection of the room itself. This scenario typically occurs when the sender can't be identified as an occupant of the room, such as, for example, changes applied through the Openfire admin console.- Parameters:
packet
- The packet to sendsender
- Representation of the entity that sent the stanza.
-
broadcast
public void broadcast(@Nonnull org.xmpp.packet.Presence presence, boolean isJoinPresence) Broadcasts the presence stanza as captured by the argument to all occupants that are local to the local domain (in other words, it excludes occupants that are connected via FMUC).- Parameters:
presence
- The presence stanzaisJoinPresence
- If the presence is sent in the context of joining the room.
-
broadcast
public void broadcast(@Nonnull org.xmpp.packet.Message message) Broadcasts the message stanza as captured by the argument to all occupants that are local to the domain (in other words, it excludes occupants that connected via FMUC). This method also ensures that the broadcast message is logged to persistent storage, if that feature is enabled for this room- Parameters:
message
- The message stanza
-
addRealJidToMessage
Based on XEP-0045, section 7.2.13: If the room is non-anonymous, the service MAY include an Extended Stanza Addressing (XEP-0033) [16] element that notes the original full JID of the sender by means of the "ofrom" address type -
getChatLength
public long getChatLength()Returns the total length of the chat session.- Returns:
- length of chat session in milliseconds.
-
addFirstOwner
public void addFirstOwner(@Nonnull org.xmpp.packet.JID targetUserAddress) Adds a new user to the list of owners. The user is the actual creator of the room. Only the MultiUserChatServer should use this method. Regular owners list maintenance MUST be done throughaddOwner(JID jid, Affiliation)
.- Parameters:
targetUserAddress
- The (real) JID of the user to add as owner.
-
addOwners
public List<org.xmpp.packet.Presence> addOwners(@Nonnull List<org.xmpp.packet.JID> targetUserAddresses, @Nonnull Affiliation actorAffiliation) throws ForbiddenException Adds a list of users to the list of owners.- Parameters:
targetUserAddresses
- the list of (real) JIDs of the users to add to the list of existing owners.actorAffiliation
- the room affiliation of the user that is trying to modify the owners list.- Returns:
- the list of updated presences of all the clients resources that the clients used to join the room.
- Throws:
ForbiddenException
- If the user is not allowed to modify the owner list.
-
addOwner
public List<org.xmpp.packet.Presence> addOwner(@Nonnull org.xmpp.packet.JID targetUserAddress, @Nonnull Affiliation actorAffiliation) throws ForbiddenException Adds a new user to the list of owners.- Parameters:
targetUserAddress
- the (real) JID of the user to add as owner.actorAffiliation
- the room affiliation of the user that is trying to modify the owners list.- Returns:
- the list of updated presences of all the client resources that the client used to join the room.
- Throws:
ForbiddenException
- If the user is not allowed to modify the owner list.
-
addAdmins
public List<org.xmpp.packet.Presence> addAdmins(@Nonnull List<org.xmpp.packet.JID> targetUserAddresses, @Nonnull Affiliation actorAffiliation) throws ForbiddenException, ConflictException Adds a list of users to the list of admins.- Parameters:
targetUserAddresses
- the list of (real) JIDs of the users to add to the list of existing admins.actorAffiliation
- the room affiliation of the user that is trying to modify the admins list.- Returns:
- the list of updated presences of all the clients resources that the clients used to join the room.
- Throws:
ForbiddenException
- If the user is not allowed to modify the admin list.ConflictException
- If the room was going to lose all its owners.
-
addAdmin
public List<org.xmpp.packet.Presence> addAdmin(@Nonnull org.xmpp.packet.JID targetUserAddress, @Nonnull Affiliation actorAffiliation) throws ForbiddenException, ConflictException Adds a new user to the list of admins.- Parameters:
targetUserAddress
- the (real) JID of the user to add as admin.actorAffiliation
- The room affiliation the user that is trying to modify the admins list.- Returns:
- the list of updated presences of all the client resources that the client used to join the room.
- Throws:
ForbiddenException
- If the user is not allowed to modify the admin list.ConflictException
- If the room was going to lose all its owners.
-
addMember
public List<org.xmpp.packet.Presence> addMember(@Nonnull org.xmpp.packet.JID targetUserAddress, @Nullable String nickname, @Nonnull Affiliation actorAffiliation) throws ForbiddenException, ConflictException Adds a new user to the list of members.- Parameters:
targetUserAddress
- The (real) JID of the user to add as a member.nickname
- The reserved nickname of the member for the room or null if none.actorAffiliation
- the room affiliation of the user that is trying to modify the members list.- Returns:
- the list of updated presences of all the client resources that the client used to join the room.
- Throws:
ForbiddenException
- If the user is not allowed to modify the members list.ConflictException
- If the desired room nickname is already reserved for the room or if the room was going to lose all its owners.
-
addOutcast
public List<org.xmpp.packet.Presence> addOutcast(@Nonnull org.xmpp.packet.JID targetUserAddress, @Nullable String reason, @Nullable org.xmpp.packet.JID actorUserAddress, @Nonnull Affiliation actorAffiliation, @Nullable Role actorRole) throws NotAllowedException, ForbiddenException, ConflictException Adds a new user to the list of outcast users.- Parameters:
targetUserAddress
- The (real) JID of the user to add as an outcast.reason
- an optional reason why the user was banned.actorUserAddress
- The (real) address of the user that initiated the ban.actorAffiliation
- The room affiliation of the user that initiated the ban.actorRole
- The room role of the user that initiated the ban (can be null when the user is currently not an occupant).- Returns:
- the list of updated presences of all the client resources that the client used to join the room.
- Throws:
NotAllowedException
- Thrown if trying to ban an owner or an administrator.ForbiddenException
- If the user is not allowed to modify the outcast list.ConflictException
- If the room was going to lose all its owners.
-
addNone
public List<org.xmpp.packet.Presence> addNone(@Nonnull org.xmpp.packet.JID targetUserAddress, @Nonnull Affiliation actorAffiliation) throws ForbiddenException, ConflictException Removes the user from all the other affiliation list thus giving the user a NONE affiliation. When kicking a user from the room, usekickOccupant(JID, Affiliation, Role, JID, String, String)
instead, which causes the role of the occupant to be changed (instead of the affiliation, which is modified by this method).- Parameters:
targetUserAddress
- The (real) JID of the user to give a NONE affiliation.actorAffiliation
- The room affiliation of the user that set the affiliation to none.- Returns:
- the list of updated presences of all the client resources that the client used to join the room or null if none was updated.
- Throws:
ForbiddenException
- If the user is not allowed to modify the none list.ConflictException
- If the room was going to lose all its owners.- See Also:
-
kickOccupant
public List<org.xmpp.packet.Presence> kickOccupant(@Nonnull org.xmpp.packet.JID userAddress, @Nonnull Affiliation actorAffiliation, @Nullable Role actorRole, @Nullable org.xmpp.packet.JID actorJID, @Nullable String actorNickname, @Nullable String reason) throws ForbiddenException, NotAllowedException Kicks a user from the room. If the user was in the room, the returned updated presence will be sent to the remaining occupants. When attempting to remove the affiliation from a user from the room, useaddNone(JID, Affiliation)
instead. Kicking a user will only cause the role of the occupant to be changed. The status code that is used in the presence stanzas that are sent as a result of the kick is '307'.- Parameters:
userAddress
- the (real) JID of the occupant to change to visitoractorJID
- The JID of the actor that initiated the kick.actorNickname
- The actor nickname.reason
- An optional reason why the user was kicked (can benull
).- Returns:
- the list of updated presences of all the client resources that the occupant has used to join the room.
- Throws:
ForbiddenException
- Thrown if trying to ban an owner or an administrator.NotAllowedException
-
kickOccupant
public List<org.xmpp.packet.Presence> kickOccupant(@Nonnull org.xmpp.packet.JID userAddress, @Nonnull Affiliation actorAffiliation, @Nullable Role actorRole, @Nullable org.xmpp.packet.JID actorJID, @Nullable String actorNickname, @Nullable String reason, int status) throws ForbiddenException, NotAllowedException Kicks a user from the room. If the user was in the room, the returned updated presence will be sent to the remaining occupants. When attempting to remove the affiliation from a user from the room, useaddNone(JID, Affiliation)
instead. Kicking a user will only cause the role of the occupant to be changed.- Parameters:
userAddress
- the (real) JID of the occupant to change to visitoractorJID
- The JID of the actor that initiated the kick.actorNickname
- The actor nickname.reason
- An optional reason why the user was kicked (can benull
).status
- The status code that references the reason for the kick (typically 307).- Returns:
- the list of updated presences of all the client resources that the occupant has used to join the room.
- Throws:
ForbiddenException
- Thrown if trying to ban an owner or an administrator.NotAllowedException
-
isLocked
public boolean isLocked()Returns true if the room is locked. The lock will persist for a defined period of time. If the room owner does not configure the room within the timeout period, the room owner is assumed to have accepted the default configuration.- Returns:
- true if the room is locked.
-
isManuallyLocked
public boolean isManuallyLocked()Returns true if the room is locked and it was locked by a room owner after the room was initially configured.- Returns:
- true if the room is locked and it was locked by a room owner after the room was initially configured.
-
presenceUpdated
An event callback fired whenever an occupant updated his presence in the chatroom. Handles occupants updating their presence in the chatroom. Assumes the user updates their presence whenever their availability in the room changes. This method should not be called to handle other presence related updates, such as nickname changes.- Parameters:
occupant
- occupant that changed his presence in the room (cannot benull
).newPresence
- presence sent by the occupant (cannot benull
).
-
nicknameChanged
public void nicknameChanged(MUCOccupant occupant, org.xmpp.packet.Presence newPresence, String oldNick, String newNick) An event callback fired whenever an occupant changes his nickname within the chatroom.- Parameters:
occupant
- occupant that changed his nickname in the room (cannot benull
).newPresence
- presence sent by the occupant with the new nickname (cannot benull
).oldNick
- old nickname within the room (cannot benull
).newNick
- new nickname within the room (cannot benull
).
-
changeSubject
public void changeSubject(org.xmpp.packet.Message packet, MUCOccupant actor) throws ForbiddenException Changes the room's subject if the occupant has enough permissions. The occupant must be a moderator or the room must be configured so that anyone can change its subject, otherwise a forbidden exception will be thrown. The new subject will be added to the history of the room.- Parameters:
packet
- the stanza used to change the room's subject (cannot benull
).actor
- the occupant that is trying to change the subject (cannot benull
).- Throws:
ForbiddenException
- If the user is not allowed to change the subject.
-
getSubject
Returns the last subject that some occupant set to the room.- Returns:
- the last subject that some occupant set to the room.
-
setSubject
Sets the last subject that some occupant set to the room. This message will only be used when loading a room from the database.- Parameters:
subject
- the last known subject of the room (cannot benull
).
-
sendInvitation
public void sendInvitation(@Nonnull org.xmpp.packet.JID to, @Nullable String reason, @Nonnull Affiliation senderAffiliation, @Nullable org.xmpp.packet.JID senderUserAddress, @Nullable List<org.dom4j.Element> extensions) throws ForbiddenException, CannotBeInvitedException Sends an invitation to a user. The invitation will be sent as if the room is inviting the user. The invitation will include the original occupant that sent the invitation together with the reason for the invitation if any. Since the invitee could be offline at the moment we need the originating session so that the offline strategy could potentially bounce the message with the invitation.- Parameters:
to
- the JID of the user that is being invited.reason
- the reason of the invitation or null if none.senderAffiliation
- the room affiliation the user that sent the invitation.senderUserAddress
- the (real) user address of the user that sent the invitation.extensions
- the list of extensions sent with the original message invitation or null if none.- Throws:
ForbiddenException
- If the user is not allowed to send the invitation.CannotBeInvitedException
- (Optionally) If the user being invited does not have access to the room
-
sendInvitationRejection
public void sendInvitationRejection(org.xmpp.packet.JID to, String reason, org.xmpp.packet.JID sender) Sends the rejection to the inviter. The rejection will be sent as if the room is rejecting the invitation is named of the invitee. The rejection will include the address of the invitee together with the reason for the rejection if any. Since the inviter could be offline at the moment we need the originating session so that the offline strategy could potentially bounce the message with the rejection.- Parameters:
to
- the JID of the user that is originated the invitation.reason
- the reason for the rejection or null if none.sender
- the JID of the invitee that is rejecting the invitation.
-
getIQOwnerHandler
-
getIQAdminHandler
-
getFmucHandler
-
getRoomHistory
Returns the history of the room which includes chat transcripts.- Returns:
- the history of the room which includes chat transcripts.
-
getOwners
Returns a collection with the current list of owners. The collection contains the bareJID of the users with owner affiliation.- Returns:
- a collection with the current list of owners.
-
getAdmins
Returns a collection with the current list of admins. The collection contains the bareJID of the users with admin affiliation.- Returns:
- a collection with the current list of admins.
-
getMembers
Returns a collection with the current list of room members. The collection contains the bareJID of the users with member affiliation. If the room is not members-only then the list will contain the users that registered with the room and therefore they may have reserved a nickname.- Returns:
- a collection with the current list of members.
-
getOutcasts
Returns a collection with the current list of outcast users. An outcast user is not allowed to join the room again. The collection contains the bareJID of the users with outcast affiliation.- Returns:
- a collection with the current list of outcast users.
-
getModerators
Returns a collection with the current list of room moderators. The collection contains the data of the occupants with moderator role.- Returns:
- a collection with the current list of moderators.
-
getParticipants
Returns a collection with the current list of room participants. The collection contains the data of the occupants with participant role.- Returns:
- a collection with the current list of moderators.
-
addModerator
public List<org.xmpp.packet.Presence> addModerator(@Nonnull org.xmpp.packet.JID targetUserAddress, @Nonnull Affiliation actorAffiliation) throws ForbiddenException Changes the role of the user within the room to moderator. A moderator is allowed to kick occupants as well as granting/revoking voice from occupants.- Parameters:
targetUserAddress
- the (real) JID of the occupant to give moderator privileges.actorAffiliation
- The room affiliation of the user that is granting moderator privileges to an occupant.- Returns:
- the list of updated presences of all the client resources that the occupant has used to join the room.
- Throws:
ForbiddenException
- If the user is not allowed to grant moderator privileges.
-
addParticipant
public List<org.xmpp.packet.Presence> addParticipant(@Nonnull org.xmpp.packet.JID targetUserAddress, @Nullable String reason, @Nonnull Affiliation actorAffiliation, @Nullable Role actorRole) throws ForbiddenException, NotAllowedException Changes the role of the user within the room to participant. A participant is allowed to send messages to the room (i.e. has voice) and may change the room's subject.- Parameters:
targetUserAddress
- the (real) JID of the occupant to give participant privileges.reason
- The reason why participant privileges were given to the user.actorAffiliation
- The room affiliation of the user that is granting participant privileges to an occupant.actorRole
- The room role of the user that is granting participant privileges to an occupant (can be null when the user is currently not an occupant).- Returns:
- the list of updated presences of all the client resources that the occupant has used to join the room.
- Throws:
ForbiddenException
- If the user is not allowed to grant participant privileges.NotAllowedException
-
addVisitor
public List<org.xmpp.packet.Presence> addVisitor(@Nonnull org.xmpp.packet.JID targetUserAddress, @Nonnull Affiliation actorAffiliation, @Nullable Role actorRole) throws ForbiddenException, NotAllowedException Changes the role of the user within the room to visitor. A visitor can receive messages but is not allowed to send messages to the room (i.e. does not have voice) and may invite others to the room.- Parameters:
targetUserAddress
- the (real) JID of the occupant to change to visitoractorAffiliation
- The room affiliation of the user that is changing the role to visitor.actorRole
- The room role of the user that is changing the role to visitor (can be null when the user is currently not an occupant).- Returns:
- the list of updated presences of all the client resources that the occupant has used to join the room.
- Throws:
ForbiddenException
- if the actor is allowed to change the role.NotAllowedException
-
canAnyoneDiscoverJID
public boolean canAnyoneDiscoverJID()Returns true if every presence packet will include the JID of every occupant. This configuration can be modified by the owner while editing the room's configuration.- Returns:
- true if every presence packet will include the JID of every occupant.
-
setCanAnyoneDiscoverJID
public void setCanAnyoneDiscoverJID(boolean canAnyoneDiscoverJID) Sets if every presence packet will include the JID of every occupant. This configuration can be modified by the owner while editing the room's configuration.- Parameters:
canAnyoneDiscoverJID
- boolean that specifies if every presence packet will include the JID of every occupant.
-
canSendPrivateMessage
Returns the minimal role of persons that are allowed to send private messages in the room. The returned value is any one of: "anyone", "moderators", "participants", "none".- Returns:
- The minimal role of persons that are allowed to send private messages in the room (never null).
-
setCanSendPrivateMessage
Sets the minimal role of persons that are allowed to send private messages in the room. The provided value is any one of: "anyone", "moderators", "participants", "none". If another value is set, "anyone" is used instead.- Parameters:
role
- The minimal role of persons that are allowed to send private messages in the room (never null).
-
canOccupantsChangeSubject
public boolean canOccupantsChangeSubject()Returns true if participants are allowed to change the room's subject.- Returns:
- true if participants are allowed to change the room's subject.
-
setCanOccupantsChangeSubject
public void setCanOccupantsChangeSubject(boolean canOccupantsChangeSubject) Sets if participants are allowed to change the room's subject.- Parameters:
canOccupantsChangeSubject
- boolean that specifies if participants are allowed to change the room's subject.
-
canOccupantsInvite
public boolean canOccupantsInvite()Returns true if occupants can invite other users to the room. If the room does not require an invitation to enter (i.e. is not members-only) then any occupant can send invitations. On the other hand, if the room is members-only and occupants cannot send invitation then only the room owners and admins are allowed to send invitations.- Returns:
- true if occupants can invite other users to the room.
-
setCanOccupantsInvite
public void setCanOccupantsInvite(boolean canOccupantsInvite) Sets if occupants can invite other users to the room. If the room does not require an invitation to enter (i.e. is not members-only) then any occupant can send invitations. On the other hand, if the room is members-only and occupants cannot send invitation then only the room owners and admins are allowed to send invitations.- Parameters:
canOccupantsInvite
- boolean that specified in any occupant can invite other users to the room.
-
getNaturalLanguageName
Returns the natural language name of the room. This name can only be modified by room owners. It's mainly used for users while discovering rooms hosted by the Multi-User Chat service.- Returns:
- the natural language name of the room.
-
setNaturalLanguageName
Sets the natural language name of the room. This name can only be modified by room owners. It's mainly used for users while discovering rooms hosted by the Multi-User Chat service.- Parameters:
naturalLanguageName
- the natural language name of the room.
-
getDescription
Returns a description set by the room's owners about the room. This information will be used when discovering extended information about the room.- Returns:
- a description set by the room's owners about the room.
-
setDescription
Sets a description set by the room's owners about the room. This information will be used when discovering extended information about the room.- Parameters:
description
- a description set by the room's owners about the room.
-
isMembersOnly
public boolean isMembersOnly()Returns true if the room requires an invitation to enter. That is if the room is members-only.- Returns:
- true if the room requires an invitation to enter.
-
setMembersOnly
public List<org.xmpp.packet.Presence> setMembersOnly(boolean membersOnly, @Nonnull Affiliation actorAffiliation, @Nullable org.xmpp.packet.JID actorJid) throws ForbiddenException, NotAllowedException Sets if the room requires an invitation to enter. That is if the room is members-only.- Parameters:
membersOnly
- if true then the room is members-only.- Returns:
- the list of updated presences of all the occupants that aren't members of the room if the room is now members-only.
- Throws:
ForbiddenException
NotAllowedException
-
isLogEnabled
public boolean isLogEnabled()Returns true if the room's conversation is being logged. If logging is activated the room conversation will be saved to the database every couple of minutes. The saving frequency is the same for all the rooms and can be configured by changing the property "xmpp.muc.tasks.log.timeout" of MultiUserChatServerImpl.- Returns:
- true if the room's conversation is being logged.
-
setPreserveHistOnRoomDeletionEnabled
public void setPreserveHistOnRoomDeletionEnabled(boolean preserveHistOnRoomDeletion) Sets if the room's conversation will be preserved when the room is deleted.- Parameters:
preserveHistOnRoomDeletion
- boolean that specified if the room's conversation will be preserved on deletion.
-
isPreserveHistOnRoomDeletionEnabled
public boolean isPreserveHistOnRoomDeletionEnabled()Returns true if the room's conversation will be preserved when the room is deleted.- Returns:
- true if the room's conversation is being logged.
-
setLogEnabled
public void setLogEnabled(boolean logEnabled) Sets if the room's conversation is being logged. If logging is activated the room conversation will be saved to the database every couple of minutes. The saving frequency is the same for all the rooms and can be configured by changing the property "xmpp.muc.tasks.log.timeout" of MultiUserChatServerImpl.- Parameters:
logEnabled
- boolean that specified if the room's conversation must be logged.
-
setLoginRestrictedToNickname
public void setLoginRestrictedToNickname(boolean restricted) Sets if registered users can only join the room using their registered nickname. A not_acceptable error will be returned if the user tries to join the room with a nickname different from the reserved nickname.- Parameters:
restricted
- if registered users can only join the room using their registered nickname.
-
isLoginRestrictedToNickname
public boolean isLoginRestrictedToNickname()Returns true if registered users can only join the room using their registered nickname. By default, registered users can join the room using any nickname. A not_acceptable error will be returned if the user tries to join the room with a nickname different from the reserved nickname.- Returns:
- true if registered users can only join the room using their registered nickname.
-
setChangeNickname
public void setChangeNickname(boolean canChange) Sets if room occupants are allowed to change their nicknames in the room. By default, occupants are allowed to change their nicknames. A not_acceptable error will be returned if an occupant tries to change his nickname and this feature is not enabled. Notice that this feature is not supported by the MUC spec so answering a not_acceptable error may break some clients.- Parameters:
canChange
- if room occupants are allowed to change their nicknames in the room.
-
canChangeNickname
public boolean canChangeNickname()Returns true if room occupants are allowed to change their nicknames in the room. By default, occupants are allowed to change their nicknames. A not_acceptable error will be returned if an occupant tries to change his nickname and this feature is not enabled. Notice that this feature is not supported by the MUC spec so answering a not_acceptable error may break some clients.- Returns:
- true if room occupants are allowed to change their nicknames in the room.
-
setRegistrationEnabled
public void setRegistrationEnabled(boolean registrationEnabled) Sets if users are allowed to register with the room. By default, room registration is enabled. A not_allowed error will be returned if a user tries to register with the room and this feature is disabled.- Parameters:
registrationEnabled
- if users are allowed to register with the room.
-
isRegistrationEnabled
public boolean isRegistrationEnabled()Returns true if users are allowed to register with the room. By default, room registration is enabled. A not_allowed error will be returned if a user tries to register with the room and this feature is disabled.- Returns:
- true if users are allowed to register with the room.
-
setFmucEnabled
public void setFmucEnabled(boolean fmucEnabled) Sets if this room accepts FMUC joins. By default, FMUC functionality is not enabled. When joining nodes are attempting a join, a rejection will be returned when this feature is disabled. -
isFmucEnabled
public boolean isFmucEnabled()Returns true if this room accepts FMUC joins. By default, FMUC functionality is not enabled. When joining nodes are attempting a join, a rejection will be returned when this feature is disabled. -
setFmucOutboundNode
public void setFmucOutboundNode(org.xmpp.packet.JID fmucOutboundNode) Sets the address of the MUC room (typically on a remote XMPP domain) to which this room should initiate FMUC federation. In this federation, the local node takes the role of the 'joining' node, while the remote node takes the role of the 'joined' node. When this room is not expected to initiate federation (note that it can still accept inbound federation attempts) then this method returns null. Although a room can accept multiple inbound joins (where it acts as a 'parent' node), it can initiate only one outbound join at a time (where it acts as a 'child' node).- Parameters:
fmucOutboundNode
- Address of peer for to-be-initiated outbound FMUC federation, possibly null.
-
getFmucOutboundNode
public org.xmpp.packet.JID getFmucOutboundNode()Returns the address of the MUC room (typically on a remote XMPP domain) to which this room should initiate FMUC federation. In this federation, the local node takes the role of the 'joining' node, while the remote node takes the role of the 'joined' node. When this room is not expected to initiate federation (note that it can still accept inbound federation attempts) then this method returns null. Although a room can accept multiple inbound joins (where it acts as a 'parent' node), it can initiate only one outbound join at a time (where it acts as a 'child' node).- Returns:
- Address of peer for to-be-initiated outbound FMUC federation, possibly null.
-
setFmucOutboundMode
Sets the 'mode' that describes the FMUC configuration is captured in the supplied object, which is either master-master or master-slave.- Parameters:
fmucOutboundMode
- FMUC mode applied to outbound FMUC federation attempts.
-
getFmucOutboundMode
Returns the 'mode' that describes the FMUC configuration is captured in the supplied object, which is either master-master or master-slave. This method should return null only when no outbound federation should be attempted.- Returns:
- FMUC mode applied to outbound FMUC federation attempts.
-
setFmucInboundNodes
A set of addresses of MUC rooms (typically on a remote XMPP domain) that defines the list of rooms that is permitted to federate with the local room. A null value is to be interpreted as allowing all rooms to be permitted. An empty set of addresses is to be interpreted as disallowing all rooms to be permitted.- Parameters:
fmucInboundNodes
- A list of rooms allowed to join, possibly empty, possibly null
-
getFmucInboundNodes
A set of addresses of MUC rooms (typically on a remote XMPP domain) that defines the list of rooms that is permitted to federate with the local room. A null value is to be interpreted as allowing all rooms to be permitted. An empty set of addresses is to be interpreted as disallowing all rooms to be permitted.- Returns:
- A list of rooms allowed to join, possibly empty, possibly null
-
getMaxUsers
public int getMaxUsers()Returns the maximum number of occupants that can be simultaneously in the room. If the number is zero then there is no limit.- Returns:
- the maximum number of occupants that can be simultaneously in the room. Zero means unlimited number of occupants.
-
setMaxUsers
public void setMaxUsers(int maxUsers) Sets the maximum number of occupants that can be simultaneously in the room. If the number is zero then there is no limit.- Parameters:
maxUsers
- the maximum number of occupants that can be simultaneously in the room. Zero means unlimited number of occupants.
-
isModerated
public boolean isModerated()Returns if the room in which only those with "voice" may send messages to all occupants.- Returns:
- if the room in which only those with "voice" may send messages to all occupants.
-
setModerated
public void setModerated(boolean moderated) Sets if the room in which only those with "voice" may send messages to all occupants.- Parameters:
moderated
- if the room in which only those with "voice" may send messages to all occupants.
-
isRetireOnDeletion
public boolean isRetireOnDeletion()Returns whether the room should be retired on deletion. Retiring a room means that this room's name cannot be used again on room deletion- Returns:
- true if the room should be retired on deletion
-
setRetireOnDeletion
public void setRetireOnDeletion(boolean retire) Sets whether the room should be retired on deletion. Retiring a room means that this room's name cannot be used again after room deletion.- Parameters:
retire
- true if the room should be retired on deletion
-
getPassword
Returns the password that the user must provide to enter the room.- Returns:
- the password that the user must provide to enter the room.
-
setPassword
Sets the password that the user must provide to enter the room.- Parameters:
password
- the password that the user must provide to enter the room.
-
isPasswordProtected
public boolean isPasswordProtected()Returns true if a user cannot enter without first providing the correct password.- Returns:
- true if a user cannot enter without first providing the correct password.
-
isPersistent
public boolean isPersistent()Returns true if the room is not destroyed if the last occupant exits. Persistent rooms are saved to the database to make their configurations persistent together with the affiliation of the users.- Returns:
- true if the room is not destroyed if the last occupant exits.
-
wasSavedToDB
public boolean wasSavedToDB()Returns true if the room has already been made persistent. If the room is temporary the answer will always be false.- Returns:
- true if the room has already been made persistent.
-
setSavedToDB
public void setSavedToDB(boolean saved) Sets if the room has already been made persistent.- Parameters:
saved
- boolean that indicates if the room was saved to the database.
-
setPersistent
public void setPersistent(boolean persistent) Sets if the room is not destroyed if the last occupant exits. Persistent rooms are saved to the database to make their configurations persistent together with the affiliation of the users.- Parameters:
persistent
- if the room is not destroyed if the last occupant exits.
-
isPublicRoom
public boolean isPublicRoom()Returns true if the room is searchable and visible through service discovery.- Returns:
- true if the room is searchable and visible through service discovery.
-
setPublicRoom
public void setPublicRoom(boolean publicRoom) Sets if the room is searchable and visible through service discovery.- Parameters:
publicRoom
- if the room is searchable and visible through service discovery.
-
getRolesToBroadcastPresence
Returns the list of roles of which presence will be broadcast to the rest of the occupants. This feature is useful for implementing "invisible" occupants.- Returns:
- the list of roles of which presence will be broadcast to the rest of the occupants.
-
setRolesToBroadcastPresence
Sets the list of roles of which presence will be broadcast to the rest of the occupants. This feature is useful for implementing "invisible" occupants.- Parameters:
rolesToBroadcastPresence
- the list of roles of which presence will be broadcast to the rest of the occupants.
-
canBroadcastPresence
Returns true if the presences of the requested role will be broadcast.- Parameters:
roleToBroadcast
- the role to check if its presences will be broadcast.- Returns:
- true if the presences of the requested role will be broadcast.
-
lock
Locks the room so that users cannot join the room. Only the owner of the room can lock/unlock the room.- Parameters:
actor
- the occupant data of the user that locked the room.- Throws:
ForbiddenException
- If the user is not an owner of the room.
-
unlock
Unlocks the room so that users can join the room. The room is locked when created and only the owner of the room can unlock it by sending the configuration form to the Multi-User Chat service.- Parameters:
actorAffiliation
- the room affiliation of the user that unlocked the room.- Throws:
ForbiddenException
- If the user is not an owner of the room.
-
setLockedDate
Sets the date when the room was locked. Initially when the room is created it is locked so the locked date is the creation date of the room. Afterwards, the room may be manually locked and unlocked so the locked date may be in these cases different from the creation date. A Date with time 0 means that the room is unlocked.- Parameters:
lockedTime
- the date when the room was locked.
-
getLockedDate
Returns the date when the room was locked. Initially when the room is created it is locked so the locked date is the creation date of the room. Afterwards, the room may be manually locked and unlocked so the locked date may be in these cases different from the creation date. When the room is unlocked a Date with time 0 is returned.- Returns:
- the date when the room was locked.
-
saveToDB
public void saveToDB()Saves the room configuration to the DB. After the room has been saved to the DB it will become persistent. -
getCachedSize
Description copied from interface:Cacheable
Returns the approximate size of the Object in bytes. The size should be considered to be a best estimate of how much memory the Object occupies and may be based on empirical trials or dynamic calculations.- Specified by:
getCachedSize
in interfaceCacheable
- Returns:
- the size of the Object in bytes.
- Throws:
CannotCalculateSizeException
- if the size cannot be calculated
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
updateConfiguration
-
toString
-
getUID
- Specified by:
getUID
in interfaceorg.xmpp.resultsetmanagement.Result
-
hashCode
public int hashCode() -
equals
-
groupDeleting
Description copied from interface:GroupEventListener
A group is being deleted.- Specified by:
groupDeleting
in interfaceGroupEventListener
- Parameters:
group
- the group.params
- event parameters.
-
groupModified
Description copied from interface:GroupEventListener
A group's name, description, or an extended property was changed.- Specified by:
groupModified
in interfaceGroupEventListener
- Parameters:
group
- the group.params
- event parameters.
-
memberAdded
Description copied from interface:GroupEventListener
A member was added to a group.- Specified by:
memberAdded
in interfaceGroupEventListener
- Parameters:
group
- the group.params
- event parameters.
-
memberRemoved
Description copied from interface:GroupEventListener
A member was removed from a group.- Specified by:
memberRemoved
in interfaceGroupEventListener
- Parameters:
group
- the group.params
- event parameters.
-
adminAdded
Description copied from interface:GroupEventListener
An administrator was added to a group.- Specified by:
adminAdded
in interfaceGroupEventListener
- Parameters:
group
- the group.params
- event parameters.
-
adminRemoved
Description copied from interface:GroupEventListener
An administrator was removed from a group.- Specified by:
adminRemoved
in interfaceGroupEventListener
- Parameters:
group
- the group.params
- event parameters.
-
groupCreated
Description copied from interface:GroupEventListener
A group was created.- Specified by:
groupCreated
in interfaceGroupEventListener
- Parameters:
group
- the group.params
- event parameters.
-
userCreated
Description copied from interface:UserEventListener
A user was created.- Specified by:
userCreated
in interfaceUserEventListener
- Parameters:
user
- the user.params
- event parameters.
-
userDeleting
Description copied from interface:UserEventListener
A user is being deleted.- Specified by:
userDeleting
in interfaceUserEventListener
- Parameters:
user
- the user.params
- event parameters.
-
userModified
Description copied from interface:UserEventListener
A user's name, email, or an extended property was changed.- Specified by:
userModified
in interfaceUserEventListener
- Parameters:
user
- the user.params
- event parameters.
-
generateOccupantId
Creates an Occupant ID based on the generation specification defined in XEP-0421.- Parameters:
userJid
- The JID for which to generate an Occupant ID- Returns:
- a hexadecimal representation of the Occupant ID
- See Also:
-