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.
Modifier and Type | Field and Description |
---|---|
protected MUCEventDelegate |
mucEventDelegate
Delegate responds to events for the MUC service.
|
long |
totalChatTime
The total time all agents took to chat *
|
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 |
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.
|
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() |
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.
|
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) |
int |
getLogConversationBatchSize()
Returns the number of messages to save to the database on each run of the logging process.
|
int |
getLogConversationsTimeout()
Returns the time to elapse between logging the room conversations.
|
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 |
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 |
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 |
setDescription(String desc) |
void |
setKickIdleUsersTimeout(int timeout)
Sets the time to elapse between clearing of idle chat users.
|
void |
setLogConversationBatchSize(int size)
Sets the number of messages to save to the database on each run of the logging process.
|
void |
setLogConversationsTimeout(int timeout)
Sets the time to elapse between logging the room conversations.
|
void |
setMUCDelegate(MUCEventDelegate delegate)
Sets the MUC event delegate handler for this service.
|
void |
setRoomCreationRestricted(boolean roomCreationRestricted)
Sets if anyone can create rooms or if only the returned JIDs in
getUsersAllowedToCreate are allowed to 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() |
public long totalChatTime
protected MUCEventDelegate mucEventDelegate
public 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 String getDescription()
getDescription
in interface org.xmpp.component.Component
public void setDescription(String desc)
public void processPacket(org.xmpp.packet.Packet packet)
processPacket
in interface org.xmpp.component.Component
public void initialize(org.xmpp.packet.JID jid, org.xmpp.component.ComponentManager componentManager)
initialize
in interface org.xmpp.component.Component
public void shutdown()
shutdown
in interface org.xmpp.component.Component
public String getServiceDomain()
MultiUserChatService
getServiceDomain
in interface MultiUserChatService
public org.xmpp.packet.JID getAddress()
public void serverStarted()
XMPPServerListener
serverStarted
in interface XMPPServerListener
public void serverStopping()
XMPPServerListener
serverStopping
in interface XMPPServerListener
public MUCRoom getChatRoom(String roomName, org.xmpp.packet.JID userjid) throws NotAllowedException
MultiUserChatService
getChatRoom
in interface MultiUserChatService
roomName
- 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)
MultiUserChatService
getChatRoom
in interface MultiUserChatService
roomName
- Name of the room to get.public void refreshChatRoom(String roomName)
MultiUserChatService
refreshChatRoom
in interface MultiUserChatService
roomName
- Name of the room to refresh.public LocalMUCRoom getLocalChatRoom(String roomName)
public List<MUCRoom> getChatRooms()
MultiUserChatService
getChatRooms
in interface MultiUserChatService
public boolean hasChatRoom(String roomName)
MultiUserChatService
hasChatRoom
in interface MultiUserChatService
roomName
- the name of the chatroom to check.public void removeChatRoom(String roomName)
MultiUserChatService
removeChatRoom
in interface MultiUserChatService
roomName
- The room to remove.public void chatRoomRemoved(LocalMUCRoom room)
chatRoomRemoved
in interface MultiUserChatService
room
- the removed room in another cluster node.public void chatRoomAdded(LocalMUCRoom room)
chatRoomAdded
in interface MultiUserChatService
room
- the created room in another cluster node.public String getServiceName()
MultiUserChatService
getServiceName
in interface MultiUserChatService
public String getName()
getName
in interface org.xmpp.component.Component
public HistoryStrategy getHistoryStrategy()
MultiUserChatService
getHistoryStrategy
in interface MultiUserChatService
public Collection<MUCRole> getMUCRoles(org.xmpp.packet.JID user)
MultiUserChatService
MUCRole
in all rooms for the specified
user's session. When running in a cluster the list will include
LocalMUCRole
and RemoteMUCRole
.getMUCRoles
in interface MultiUserChatService
user
- the full JID that identifies the session of the user.public void setKickIdleUsersTimeout(int timeout)
MultiUserChatService
TimerTask
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 MultiUserChatService
timeout
- the time to elapse between clearing of idle chat users.public int getKickIdleUsersTimeout()
MultiUserChatService
MultiUserChatService.getUserIdleTime()
.getKickIdleUsersTimeout
in interface MultiUserChatService
public void setUserIdleTime(int idleTime)
MultiUserChatService
setUserIdleTime
in interface MultiUserChatService
idleTime
- the amount of time to wait before considering a user idle.public int getUserIdleTime()
MultiUserChatService
getUserIdleTime
in interface MultiUserChatService
public void setLogConversationsTimeout(int timeout)
MultiUserChatService
TimerTask
will
be added to a Timer
scheduled for repeated fixed-delay execution whose main
responsibility is to log queued rooms conversations. The number of queued conversations to
save on each run can be configured. See MultiUserChatService.setLogConversationBatchSize(int)
.setLogConversationsTimeout
in interface MultiUserChatService
timeout
- the time to elapse between logging the room conversations.public int getLogConversationsTimeout()
MultiUserChatService
TimerTask
will be added to a Timer
scheduled for repeated fixed-delay execution whose main
responsibility is to log queued rooms conversations. The number of queued conversations to
save on each run can be configured. See MultiUserChatService.getLogConversationBatchSize()
.getLogConversationsTimeout
in interface MultiUserChatService
public void setLogConversationBatchSize(int size)
MultiUserChatService
setLogConversationBatchSize
in interface MultiUserChatService
size
- the number of messages to save to the database on each run of the logging process.public int getLogConversationBatchSize()
MultiUserChatService
getLogConversationBatchSize
in interface MultiUserChatService
public Collection<org.xmpp.packet.JID> getUsersAllowedToCreate()
MultiUserChatService
getUsersAllowedToCreate
in interface MultiUserChatService
public Collection<org.xmpp.packet.JID> getSysadmins()
MultiUserChatService
getSysadmins
in interface MultiUserChatService
public boolean isSysadmin(org.xmpp.packet.JID bareJID)
MultiUserChatService
isSysadmin
in interface MultiUserChatService
public void addSysadmins(Collection<org.xmpp.packet.JID> userJIDs)
MultiUserChatService
addSysadmins
in interface MultiUserChatService
userJIDs
- the JIDs of the new users/groups to add as a system administrator.public void addSysadmin(org.xmpp.packet.JID userJID)
MultiUserChatService
addSysadmin
in interface MultiUserChatService
userJID
- the bare JID of the new user/group to add as a system administrator.public void removeSysadmin(org.xmpp.packet.JID userJID)
MultiUserChatService
removeSysadmin
in interface MultiUserChatService
userJID
- 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()
MultiUserChatService
getUsersAllowedToCreate
are allowed to create rooms.isRoomCreationRestricted
in interface MultiUserChatService
public void setRoomCreationRestricted(boolean roomCreationRestricted)
MultiUserChatService
getUsersAllowedToCreate
are allowed to create rooms.setRoomCreationRestricted
in interface MultiUserChatService
roomCreationRestricted
- whether anyone can create rooms or not.public void addUsersAllowedToCreate(Collection<org.xmpp.packet.JID> userJIDs)
MultiUserChatService
addUsersAllowedToCreate
in interface MultiUserChatService
userJIDs
- collection of JIDs for users/groups to add to list.public void addUserAllowedToCreate(org.xmpp.packet.JID userJID)
MultiUserChatService
addUserAllowedToCreate
in interface MultiUserChatService
userJID
- the JID of the new user/group to add to list.public void removeUsersAllowedToCreate(Collection<org.xmpp.packet.JID> userJIDs)
MultiUserChatService
removeUsersAllowedToCreate
in interface MultiUserChatService
userJIDs
- collection of JIDs of users/groups to remove from the list.public void removeUserAllowedToCreate(org.xmpp.packet.JID userJID)
MultiUserChatService
removeUserAllowedToCreate
in interface MultiUserChatService
userJID
- the JID of the user/group to remove from the list.public void initialize(XMPPServer server)
public void initializeSettings()
public void start()
start
in interface org.xmpp.component.Component
public void enableService(boolean enabled, boolean persistent)
MultiUserChatService
enableService
in interface MultiUserChatService
enabled
- true if the service is enabled.persistent
- true if the new setting will persist across restarts.public boolean isServiceEnabled()
MultiUserChatService
MultiUserChatService.enableService(boolean, boolean)
to
enable or disable the service.isServiceEnabled
in interface MultiUserChatService
public long getTotalChatTime()
MultiUserChatService
getTotalChatTime
in interface MultiUserChatService
public int getNumberChatRooms()
getNumberChatRooms
in interface MultiUserChatService
public int getNumberConnectedUsers(boolean onlyLocal)
getNumberConnectedUsers
in interface MultiUserChatService
onlyLocal
- true if only users connected to this JVM will be considered. Otherwise count cluster wise.public int getNumberRoomOccupants()
getNumberRoomOccupants
in interface MultiUserChatService
public long getIncomingMessageCount(boolean resetAfter)
getIncomingMessageCount
in interface MultiUserChatService
resetAfter
- True if you want the counter to be reset after results returned.public long getOutgoingMessageCount(boolean resetAfter)
getOutgoingMessageCount
in interface MultiUserChatService
resetAfter
- 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)
MultiUserChatService
Note: 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 MultiUserChatService
room
- 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)
MultiUserChatService
messageBroadcastedTo
in interface MultiUserChatService
numOccupants
- number of occupants that received the message.public Iterator<DiscoServerItem> getItems()
ServerItemsProvider
getItems
in interface ServerItemsProvider
public Iterator<org.dom4j.Element> getIdentities(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProvider
getIdentities
in interface DiscoInfoProvider
name
- 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)
DiscoInfoProvider
getFeatures
in interface DiscoInfoProvider
name
- 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)
DiscoInfoProvider
getExtendedInfo
in interface DiscoInfoProvider
name
- 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)
feature
- Feature to add.public void removeExtraFeature(String feature)
feature
- Feature to remove.public void addExtraIdentity(String category, String name, String type)
category
- Category for identity. e.g. conferencename
- Descriptive name for identity. e.g. Public Chatroomstype
- Type for identity. e.g. textpublic void removeExtraIdentity(String name)
name
- 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)
DiscoInfoProvider
hasInfo
in interface DiscoInfoProvider
name
- 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)
DiscoItemsProvider
getItems
in interface DiscoItemsProvider
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco items request.public boolean isHidden()
MultiUserChatService
isHidden
in interface MultiUserChatService
Copyright © 2003-2008 Jive Software.