public class MultiUserChatServiceImpl extends Object implements org.xmpp.component.Component, MultiUserChatService, ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider, XMPPServerListener
Temporary rooms are held in memory as long as they have occupants. They will be destroyed after the last occupant left the room. On the other hand, persistent rooms are always present in memory even after the last occupant left the room. In order to keep memory clean of persistent rooms that have been forgotten or abandoned this class includes a clean up process. The clean up process will remove from memory rooms that haven't had occupants for a while. Moreover, forgotten or abandoned rooms won't be loaded into memory when the Multi-User Chat service starts up.
| Constructor and Description |
|---|
MultiUserChatServiceImpl(String subdomain,
String description,
Boolean isHidden)
Create a new group chat server.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExtraFeature(String feature)
Adds an extra Disco feature to the list of features returned for the conference service.
|
void |
addExtraIdentity(String category,
String name,
String type)
Adds an extra Disco identity to the list of identities returned for the conference service.
|
void |
addIQHandler(IQHandler iqHandler)
Add a IQHandler to MUC rooms and services.
|
void |
addSysadmin(org.xmpp.packet.JID userJID)
Adds a new system administrator of the MUC service.
|
void |
addSysadmins(Collection<org.xmpp.packet.JID> userJIDs)
Adds multiple system administrators for the MUC service.
|
void |
addUserAllowedToCreate(org.xmpp.packet.JID userJID)
Adds a new user/group to the list of JIDs that are allowed to create MUC rooms.
|
void |
addUsersAllowedToCreate(Collection<org.xmpp.packet.JID> userJIDs)
Adds new users/groups to the list of JIDs that are allowed to create MUC rooms.
|
boolean |
canDiscoverRoom(MUCRoom room,
org.xmpp.packet.JID entity)
Checks if the a particular entity is allowed to discover the room's existence.
|
void |
chatRoomAdded(LocalMUCRoom room)
Notification message indicating that a chat room has been created
in another cluster member.
|
void |
chatRoomRemoved(LocalMUCRoom room)
Notification message indicating that the specified chat room was
removed from some other cluster member.
|
void |
enableService(boolean enabled,
boolean persistent)
Enables or disables the MUC service.
|
org.xmpp.packet.JID |
getAddress() |
Archiver<org.jivesoftware.openfire.muc.spi.ConversationLogEntry> |
getArchiver() |
MUCRoom |
getChatRoom(String roomName)
Obtains a chatroom by name.
|
MUCRoom |
getChatRoom(String roomName,
org.xmpp.packet.JID userjid)
Obtains a chatroom by name.
|
List<MUCRoom> |
getChatRooms()
Retuns a list with a snapshot of all the rooms in the server (i.e.
|
String |
getDescription() |
org.xmpp.forms.DataForm |
getExtendedInfo(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns an XDataForm with the extended information about the entity or null if none.
|
Set<org.xmpp.forms.DataForm> |
getExtendedInfos(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns a collection of XDataForm with the extended information about the
entity or an empty collection if none.
|
Iterator<String> |
getFeatures(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns an Iterator (of String) with the supported features.
|
HistoryStrategy |
getHistoryStrategy()
Obtain the server-wide default message history settings.
|
Iterator<org.dom4j.Element> |
getIdentities(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns an Iterator (of Element) with the target entity's identities.
|
long |
getIncomingMessageCount(boolean resetAfter)
Returns the total number of incoming messages since last reset.
|
Iterator<DiscoServerItem> |
getItems()
Returns an Iterator (of DiscoServerItem) with the items associated with the server or null
if none.
|
Iterator<DiscoItem> |
getItems(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns an Iterator (of DiscoItem) with the target entity's items or null if none.
|
int |
getKickIdleUsersTimeout()
Returns the time to elapse between clearing of idle chat users.
|
LocalMUCRoom |
getLocalChatRoom(String roomName) |
Duration |
getLogMaxBatchInterval() |
int |
getLogMaxConversationBatchSize() |
MUCEventDelegate |
getMUCDelegate()
Gets the MUC event delegate handler for this service.
|
Collection<MUCRole> |
getMUCRoles(org.xmpp.packet.JID user)
Returns the list of
MUCRole in all rooms for the specified
user's session. |
String |
getName() |
int |
getNumberChatRooms()
Retuns the number of existing rooms in the server (i.e.
|
int |
getNumberConnectedUsers(boolean onlyLocal)
Retuns the total number of occupants in all rooms in the server.
|
int |
getNumberRoomOccupants()
Retuns the total number of users that have joined in all rooms in the server.
|
long |
getOutgoingMessageCount(boolean resetAfter)
Returns the total number of outgoing messages since last reset.
|
String |
getServiceDomain()
Returns the fully-qualifed domain name of this chat service.
|
String |
getServiceName()
Returns the subdomain of the chat service.
|
Collection<org.xmpp.packet.JID> |
getSysadmins()
Returns the collection of JIDs that are system administrators of the MUC service.
|
long |
getTotalChatTime()
Returns the total chat time of all rooms combined.
|
int |
getUserIdleTime()
Returns the number of milliseconds a user must be idle before he/she gets kicked from all
the rooms.
|
Collection<org.xmpp.packet.JID> |
getUsersAllowedToCreate()
Returns the collection of JIDs that are allowed to create MUC rooms.
|
boolean |
hasChatRoom(String roomName)
Returns true if the server includes a chatroom with the requested name.
|
boolean |
hasInfo(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns true if we can provide information related to the requested name and node.
|
void |
initialize(org.xmpp.packet.JID jid,
org.xmpp.component.ComponentManager componentManager) |
void |
initialize(XMPPServer server) |
void |
initializeSettings() |
boolean |
isAllowToDiscoverLockedRooms()
Returns the flag that indicates if the service should provide information about locked rooms
when handling service discovery requests.
|
boolean |
isAllowToDiscoverMembersOnlyRooms()
Returns the flag that indicates if the service should provide information about non-public
members-only rooms when handling service discovery requests.
|
boolean |
isAllRegisteredUsersAllowedToCreate()
Sets if all registered users of Openfire are allowed to create rooms.
|
boolean |
isHidden()
Returns true if the MUC service is a hidden, externally managed, service.
|
boolean |
isRoomCreationRestricted()
Returns false if anyone can create rooms or true if only the returned JIDs in
getUsersAllowedToCreate are allowed to create rooms. |
boolean |
isServiceEnabled()
Returns true if the MUC service is available.
|
boolean |
isSysadmin(org.xmpp.packet.JID bareJID)
Validates the given JID as a MUC service administrator.
|
void |
logConversation(MUCRoom room,
org.xmpp.packet.Message message,
org.xmpp.packet.JID sender)
Logs that a given message was sent to a room as part of a conversation.
|
void |
messageBroadcastedTo(int numOccupants)
Notification message indicating the server that an incoming message was broadcasted
to a given number of occupants.
|
void |
processPacket(org.xmpp.packet.Packet packet) |
void |
refreshChatRoom(String roomName)
Forces a re-read of the room.
|
void |
removeChatRoom(String roomName)
Removes the room associated with the given name.
|
void |
removeExtraFeature(String feature)
Removes an extra Disco feature from the list of features returned for the conference service.
|
void |
removeExtraIdentity(String name)
Removes an extra Disco identity from the list of identities returned for the conference service.
|
void |
removeIQHandler(IQHandler iqHandler) |
void |
removeSysadmin(org.xmpp.packet.JID userJID)
Removes a system administrator of the MUC service.
|
void |
removeUserAllowedToCreate(org.xmpp.packet.JID userJID)
Removes a user/group from list of JIDs that are allowed to create MUC rooms.
|
void |
removeUsersAllowedToCreate(Collection<org.xmpp.packet.JID> userJIDs)
Removes users/groups from list of JIDs that are allowed to create MUC rooms.
|
void |
serverStarted()
Notification message indicating that the server has been started.
|
void |
serverStopping()
Notification message indication that the server is about to be stopped.
|
void |
setAllowToDiscoverLockedRooms(boolean allowToDiscoverLockedRooms)
Sets the flag that indicates if the service should provide information about locked rooms
when handling service discovery requests.
|
void |
setAllowToDiscoverMembersOnlyRooms(boolean allowToDiscoverMembersOnlyRooms)
Sets the flag that indicates if the service should provide information about non-public
members-only rooms when handling service discovery requests.
|
void |
setAllRegisteredUsersAllowedToCreate(boolean allow)
Sets if all registered users of Openfire are allowed to create rooms.
|
void |
setDescription(String desc) |
void |
setKickIdleUsersTimeout(int timeout)
Sets the time to elapse between clearing of idle chat users.
|
void |
setLogBatchGracePeriod(Duration period) |
void |
setLogMaxBatchInterval(Duration interval) |
void |
setLogMaxConversationBatchSize(int size) |
void |
setMUCDelegate(MUCEventDelegate delegate)
Sets the MUC event delegate handler for this service.
|
void |
setRoomCreationRestricted(boolean roomCreationRestricted)
Sets if anyone can create rooms.
|
void |
setUserIdleTime(int idleTime)
Sets the number of milliseconds a user must be idle before he/she gets kicked from all
the rooms.
|
void |
shutdown() |
void |
start() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLogConversationBatchSize, getLogConversationsTimeout, isPasswordRequiredForSysadminsToJoinRoom, setLogConversationBatchSize, setLogConversationsTimeout, setPasswordRequiredForSysadminsToJoinRoompublic MultiUserChatServiceImpl(String subdomain, String description, Boolean isHidden)
subdomain - Subdomain portion of the conference services (for example,
conference for conference.example.org)description - Short description of service for disco and such. If
null or empty, a default value will be used.isHidden - True if this service should be hidden from services views.IllegalArgumentException - if the provided subdomain is an invalid, according to the JID
domain definition.public void addIQHandler(IQHandler iqHandler)
MultiUserChatServiceaddIQHandler in interface MultiUserChatServiceiqHandler - the IQ handler to addpublic void removeIQHandler(IQHandler iqHandler)
removeIQHandler in interface MultiUserChatServicepublic String getDescription()
getDescription in interface org.xmpp.component.Componentpublic void setDescription(String desc)
public void processPacket(org.xmpp.packet.Packet packet)
processPacket in interface org.xmpp.component.Componentpublic void initialize(org.xmpp.packet.JID jid,
org.xmpp.component.ComponentManager componentManager)
initialize in interface org.xmpp.component.Componentpublic void shutdown()
shutdown in interface org.xmpp.component.Componentpublic String getServiceDomain()
MultiUserChatServicegetServiceDomain in interface MultiUserChatServicepublic org.xmpp.packet.JID getAddress()
public void serverStarted()
XMPPServerListenerserverStarted in interface XMPPServerListenerpublic void serverStopping()
XMPPServerListenerserverStopping in interface XMPPServerListenerpublic Archiver<org.jivesoftware.openfire.muc.spi.ConversationLogEntry> getArchiver()
getArchiver in interface MultiUserChatServicepublic MUCRoom getChatRoom(String roomName, org.xmpp.packet.JID userjid) throws NotAllowedException
MultiUserChatServicegetChatRoom in interface MultiUserChatServiceroomName - Name of the room to get.userjid - The user's normal jid, not the chat nickname jid.NotAllowedException - If the caller doesn't have permission to create a new room.public MUCRoom getChatRoom(String roomName)
MultiUserChatServicegetChatRoom in interface MultiUserChatServiceroomName - Name of the room to get.public void refreshChatRoom(String roomName)
MultiUserChatServicerefreshChatRoom in interface MultiUserChatServiceroomName - Name of the room to refresh.public LocalMUCRoom getLocalChatRoom(String roomName)
public List<MUCRoom> getChatRooms()
MultiUserChatServicegetChatRooms in interface MultiUserChatServicepublic boolean hasChatRoom(String roomName)
MultiUserChatServicehasChatRoom in interface MultiUserChatServiceroomName - the name of the chatroom to check.public void removeChatRoom(String roomName)
MultiUserChatServiceremoveChatRoom in interface MultiUserChatServiceroomName - The room to remove.public void chatRoomRemoved(LocalMUCRoom room)
chatRoomRemoved in interface MultiUserChatServiceroom - the removed room in another cluster node.public void chatRoomAdded(LocalMUCRoom room)
chatRoomAdded in interface MultiUserChatServiceroom - the created room in another cluster node.public String getServiceName()
MultiUserChatServicegetServiceName in interface MultiUserChatServicepublic String getName()
getName in interface org.xmpp.component.Componentpublic HistoryStrategy getHistoryStrategy()
MultiUserChatServicegetHistoryStrategy in interface MultiUserChatServicepublic Collection<MUCRole> getMUCRoles(org.xmpp.packet.JID user)
MultiUserChatServiceMUCRole in all rooms for the specified
user's session. When running in a cluster the list will include
LocalMUCRole and RemoteMUCRole.getMUCRoles in interface MultiUserChatServiceuser - the full JID that identifies the session of the user.public void setKickIdleUsersTimeout(int timeout)
MultiUserChatServiceTimerTask will be
added to a Timer scheduled for repeated fixed-delay execution whose main
responsibility is to kick users that have been idle for a certain time. A user is considered
idle if he/she didn't send any message to any group chat room for a certain amount of time.
See MultiUserChatService.setUserIdleTime(int).setKickIdleUsersTimeout in interface MultiUserChatServicetimeout - the time to elapse between clearing of idle chat users.public int getKickIdleUsersTimeout()
MultiUserChatServiceMultiUserChatService.getUserIdleTime().getKickIdleUsersTimeout in interface MultiUserChatServicepublic void setUserIdleTime(int idleTime)
MultiUserChatServicesetUserIdleTime in interface MultiUserChatServiceidleTime - the amount of time to wait before considering a user idle.public int getUserIdleTime()
MultiUserChatServicegetUserIdleTime in interface MultiUserChatServicepublic Collection<org.xmpp.packet.JID> getUsersAllowedToCreate()
MultiUserChatServiceisAllRegisteredUsersAllowedToCreate, this method will
not return a JID of every user in the system.getUsersAllowedToCreate in interface MultiUserChatServicepublic Collection<org.xmpp.packet.JID> getSysadmins()
MultiUserChatServicegetSysadmins in interface MultiUserChatServicepublic boolean isSysadmin(org.xmpp.packet.JID bareJID)
MultiUserChatServiceisSysadmin in interface MultiUserChatServicebareJID - the bare JID of the userpublic void addSysadmins(Collection<org.xmpp.packet.JID> userJIDs)
MultiUserChatServiceaddSysadmins in interface MultiUserChatServiceuserJIDs - the JIDs of the new users/groups to add as a system administrator.public void addSysadmin(org.xmpp.packet.JID userJID)
MultiUserChatServiceaddSysadmin in interface MultiUserChatServiceuserJID - the bare JID of the new user/group to add as a system administrator.public void removeSysadmin(org.xmpp.packet.JID userJID)
MultiUserChatServiceremoveSysadmin in interface MultiUserChatServiceuserJID - the bare JID of the user/group to remove from the list.public boolean isAllowToDiscoverMembersOnlyRooms()
public void setAllowToDiscoverMembersOnlyRooms(boolean allowToDiscoverMembersOnlyRooms)
allowToDiscoverMembersOnlyRooms - if the service should provide information about
non-public members-only rooms.public boolean isAllowToDiscoverLockedRooms()
public void setAllowToDiscoverLockedRooms(boolean allowToDiscoverLockedRooms)
allowToDiscoverLockedRooms - if the service should provide information about locked
rooms.public boolean isRoomCreationRestricted()
MultiUserChatServicegetUsersAllowedToCreate are allowed to create rooms.isRoomCreationRestricted in interface MultiUserChatServicepublic void setRoomCreationRestricted(boolean roomCreationRestricted)
MultiUserChatServiceisAllRegisteredUsersAllowedToCreate
or getUsersAllowedToCreate (or both) allow them to.setRoomCreationRestricted in interface MultiUserChatServiceroomCreationRestricted - whether anyone can create rooms or not.public boolean isAllRegisteredUsersAllowedToCreate()
MultiUserChatServiceaddUserAllowedToCreate.isAllRegisteredUsersAllowedToCreate in interface MultiUserChatServicepublic void setAllRegisteredUsersAllowedToCreate(boolean allow)
MultiUserChatServicesetAllRegisteredUsersAllowedToCreate in interface MultiUserChatServiceallow - whether all registered users can create rooms.public void addUsersAllowedToCreate(Collection<org.xmpp.packet.JID> userJIDs)
MultiUserChatServiceaddUsersAllowedToCreate in interface MultiUserChatServiceuserJIDs - collection of JIDs for users/groups to add to list.public void addUserAllowedToCreate(org.xmpp.packet.JID userJID)
MultiUserChatServiceaddUserAllowedToCreate in interface MultiUserChatServiceuserJID - the JID of the new user/group to add to list.public void removeUsersAllowedToCreate(Collection<org.xmpp.packet.JID> userJIDs)
MultiUserChatServiceremoveUsersAllowedToCreate in interface MultiUserChatServiceuserJIDs - collection of JIDs of users/groups to remove from the list.public void removeUserAllowedToCreate(org.xmpp.packet.JID userJID)
MultiUserChatServiceremoveUserAllowedToCreate in interface MultiUserChatServiceuserJID - the JID of the user/group to remove from the list.public void initialize(XMPPServer server)
public void initializeSettings()
public void setLogMaxConversationBatchSize(int size)
public int getLogMaxConversationBatchSize()
public void setLogMaxBatchInterval(Duration interval)
public Duration getLogMaxBatchInterval()
public void setLogBatchGracePeriod(Duration period)
public void start()
start in interface org.xmpp.component.Componentpublic void enableService(boolean enabled,
boolean persistent)
MultiUserChatServiceenableService in interface MultiUserChatServiceenabled - true if the service is enabled.persistent - true if the new setting will persist across restarts.public boolean isServiceEnabled()
MultiUserChatServiceMultiUserChatService.enableService(boolean, boolean) to
enable or disable the service.isServiceEnabled in interface MultiUserChatServicepublic long getTotalChatTime()
MultiUserChatServicegetTotalChatTime in interface MultiUserChatServicepublic int getNumberChatRooms()
getNumberChatRooms in interface MultiUserChatServicepublic int getNumberConnectedUsers(boolean onlyLocal)
getNumberConnectedUsers in interface MultiUserChatServiceonlyLocal - true if only users connected to this JVM will be considered. Otherwise count cluster wise.public int getNumberRoomOccupants()
getNumberRoomOccupants in interface MultiUserChatServicepublic long getIncomingMessageCount(boolean resetAfter)
getIncomingMessageCount in interface MultiUserChatServiceresetAfter - True if you want the counter to be reset after results returned.public long getOutgoingMessageCount(boolean resetAfter)
getOutgoingMessageCount in interface MultiUserChatServiceresetAfter - True if you want the counter to be reset after results returned.public void logConversation(MUCRoom room, org.xmpp.packet.Message message, org.xmpp.packet.JID sender)
MultiUserChatServiceNote: For performane reasons, the logged message won't be immediately saved. Instead we keep the logged messages in memory until the logging process saves them to the database. It's possible to configure the logging process to run every X milliseconds and also the number of messages to log on each execution.
logConversation in interface MultiUserChatServiceroom - the room that received the message.message - the message to log as part of the conversation in the room.sender - the real XMPPAddress of the sender (e.g. john@example.org).initialize(org.jivesoftware.openfire.XMPPServer)public void messageBroadcastedTo(int numOccupants)
MultiUserChatServicemessageBroadcastedTo in interface MultiUserChatServicenumOccupants - number of occupants that received the message.public Iterator<DiscoServerItem> getItems()
ServerItemsProvidergetItems in interface ServerItemsProviderpublic Iterator<org.dom4j.Element> getIdentities(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProvidergetIdentities in interface DiscoInfoProvidername - the recipient JID's name.node - the requested disco node.senderJID - the XMPPAddress of user that sent the disco info request.public Iterator<String> getFeatures(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProvidergetFeatures in interface DiscoInfoProvidername - the recipient JID's name.node - the requested disco node.senderJID - the XMPPAddress of user that sent the disco info request.public org.xmpp.forms.DataForm getExtendedInfo(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProvidergetExtendedInfo in interface DiscoInfoProvidername - the recipient JID's name.node - the requested disco node.senderJID - the XMPPAddress of user that sent the disco info request.public Set<org.xmpp.forms.DataForm> getExtendedInfos(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProvidergetExtendedInfos in interface DiscoInfoProvidername - the recipient JID's name.node - the requested disco node.senderJID - the XMPPAddress of user that sent the disco info request.public void addExtraFeature(String feature)
addExtraFeature in interface MultiUserChatServicefeature - Feature to add.public void removeExtraFeature(String feature)
removeExtraFeature in interface MultiUserChatServicefeature - Feature to remove.public void addExtraIdentity(String category, String name, String type)
addExtraIdentity in interface MultiUserChatServicecategory - Category for identity. e.g. conferencename - Descriptive name for identity. e.g. Public Chatroomstype - Type for identity. e.g. textpublic void removeExtraIdentity(String name)
removeExtraIdentity in interface MultiUserChatServicename - Name of identity to remove.public void setMUCDelegate(MUCEventDelegate delegate)
delegate - Handler for MUC events.public MUCEventDelegate getMUCDelegate()
public boolean hasInfo(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProviderhasInfo in interface DiscoInfoProvidername - the recipient JID's name.node - the requested disco node.senderJID - the XMPPAddress of user that sent the disco info request.public Iterator<DiscoItem> getItems(String name, String node, org.xmpp.packet.JID senderJID)
DiscoItemsProvidergetItems in interface DiscoItemsProvidername - the recipient JID's name.node - the requested disco node.senderJID - the XMPPAddress of user that sent the disco items request.public boolean canDiscoverRoom(MUCRoom room, org.xmpp.packet.JID entity)
MultiUserChatServicecanDiscoverRoom in interface MultiUserChatServiceroom - The room to be discovered (cannot be null).entity - The JID of the entity (cannot be null).public boolean isHidden()
MultiUserChatServiceisHidden in interface MultiUserChatServiceCopyright © 2003–2020 Ignite Realtime. All rights reserved.