|
Wildfire 3.1.1 Javadoc | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jivesoftware.wildfire.container.BasicModule
org.jivesoftware.wildfire.muc.spi.MultiUserChatServerImpl
public class MultiUserChatServerImpl
Implements the chat server as a cached memory resident chat server. The server is also responsible for responding Multi-User Chat disco requests as well as removing inactive users from the rooms after a period of time and to maintain a log of the conversation in the rooms that require to log their conversations. The conversations log is saved to the database using a separate process
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 peristent rooms that have been forgotten or abandonded 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.
| Field Summary | |
|---|---|
long |
totalChatTime
The total time all agents took to chat * |
| Constructor Summary | |
|---|---|
MultiUserChatServerImpl()
Create a new group chat server. |
|
| Method Summary | |
|---|---|
void |
addSysadmin(String userJID)
Adds a new system administrator of the MUC service. |
void |
addUserAllowedToCreate(String userJID)
Adds a new user to the list of JIDs that are allowed to create MUC rooms. |
void |
enableService(boolean enabled)
Enables or disables the MUC service. |
JID |
getAddress()
Returns the XMPP address. |
MUCRoom |
getChatRoom(String roomName)
Obtains a chatroom by name. |
MUCRoom |
getChatRoom(String roomName,
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. |
MUCUser |
getChatUser(JID userjid)
Obtain a chat user by XMPPAddress. |
String |
getDescription()
Returns the description of this component. |
XDataFormImpl |
getExtendedInfo(String name,
String node,
JID senderJID)
Returns an XDataForm with the extended information about the entity or null if none. |
Iterator<String> |
getFeatures(String name,
String node,
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,
JID senderJID)
Returns an Iterator (of Element) with the target entity's identities. |
Iterator<DiscoServerItem> |
getItems()
Returns an Iterator (of DiscoServerItem) with the items associated with the server or null if none. |
Iterator<org.dom4j.Element> |
getItems(String name,
String node,
JID senderJID)
Returns an Iterator (of Element) with the target entity's items or null if none. |
int |
getKickIdleUsersTimeout()
Returns the time to elapse between clearing of idle chat users. |
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. |
int |
getNumberChatRooms()
Retuns the number of existing rooms in the server (i.e. |
int |
getNumberConnectedUsers()
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. |
String |
getServiceDomain()
Returns the fully-qualifed domain name of this chat service. |
String |
getServiceName()
Returns the subdomain of the chat service. |
Collection<String> |
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<String> |
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,
JID senderJID)
Returns true if we can provide information related to the requested name and node. |
void |
initialize(JID jid,
ComponentManager componentManager)
Initializes this component with a ComponentManager and the JID that this component is available at (e.g. |
void |
initialize(XMPPServer server)
Initializes the basic module. |
boolean |
isAllowToDiscoverLockedRooms()
Returns the flag that indicates if the service should provide information about locked rooms when handling service discovery requests. |
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. |
void |
logConversation(MUCRoom room,
Message message,
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 |
process(Packet packet)
Process an XMPP packet. |
void |
processPacket(Packet packet)
Processes a packet sent to this Component. |
void |
removeChatRoom(String roomName)
Removes the room associated with the given name. |
void |
removeSysadmin(String userJID)
Removes a system administrator of the MUC service. |
void |
removeUser(JID jabberID)
Removes a user from all chat rooms. |
void |
removeUserAllowedToCreate(String userJID)
Removes a user from list of JIDs that are allowed to create MUC rooms. |
void |
serverBroadcast(String msg)
Broadcast a given message to all members of this chat room. |
void |
setAllowToDiscoverLockedRooms(boolean allowToDiscoverLockedRooms)
Sets the flag that indicates if the service should provide information about locked rooms when handling service discovery requests. |
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 |
setRoomCreationRestricted(boolean roomCreationRestricted)
Sets if anyone can create rooms or if only the returned JIDs in getUsersAllowedToCreate are allowed to create rooms. |
void |
setServiceName(String name)
Set the name of this chat service. |
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()
Shuts down this component. |
void |
start()
Starts the basic module. |
void |
stop()
Stops the basic module. |
| Methods inherited from class org.jivesoftware.wildfire.container.BasicModule |
|---|
destroy, getName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.xmpp.component.Component |
|---|
getName |
| Field Detail |
|---|
public long totalChatTime
| Constructor Detail |
|---|
public MultiUserChatServerImpl()
| Method Detail |
|---|
public String getDescription()
Component
getDescription in interface Component
public void process(Packet packet)
throws UnauthorizedException,
PacketException
ChannelHandler
process in interface ChannelHandlerpacket - a packet to process.
UnauthorizedException - if not allowed to process the packet.
PacketException - thrown if the packet is malformed (results in the sender's
session being shutdown).public void processPacket(Packet packet)
Component
processPacket in interface Componentpacket - the packet.ComponentManager.sendPacket(Component, Packet)
public void initialize(JID jid,
ComponentManager componentManager)
ComponentThe initialization code must not rely on receiving packets from the server since the component has not been fully initialized yet. This means that at this point the component must not rely on information that is obtained from the server such us discovered items.
initialize in interface Componentjid - the XMPP address that this component is available at.componentManager - the component manager.public void shutdown()
Component
shutdown in interface Componentpublic String getServiceDomain()
MultiUserChatServer
getServiceDomain in interface MultiUserChatServerpublic JID getAddress()
RoutableChannelHandler
getAddress in interface RoutableChannelHandler
public MUCRoom getChatRoom(String roomName,
JID userjid)
throws NotAllowedException
MultiUserChatServer
getChatRoom in interface MultiUserChatServerroomName - 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)
MultiUserChatServer
getChatRoom in interface MultiUserChatServerroomName - Name of the room to get.
public List<MUCRoom> getChatRooms()
MultiUserChatServer
getChatRooms in interface MultiUserChatServerpublic boolean hasChatRoom(String roomName)
MultiUserChatServer
hasChatRoom in interface MultiUserChatServerroomName - the name of the chatroom to check.
public void removeChatRoom(String roomName)
MultiUserChatServer
removeChatRoom in interface MultiUserChatServerroomName - The room to remove.public String getServiceName()
MultiUserChatServer
getServiceName in interface MultiUserChatServerpublic HistoryStrategy getHistoryStrategy()
MultiUserChatServer
getHistoryStrategy in interface MultiUserChatServerpublic void removeUser(JID jabberID)
MultiUserChatServer
removeUser in interface MultiUserChatServerjabberID - The user's normal jid, not the chat nickname jid.
public MUCUser getChatUser(JID userjid)
throws UserNotFoundException
MultiUserChatServer
getChatUser in interface MultiUserChatServeruserjid - The XMPPAddress of the user.
UserNotFoundException - If the user is not found and can't be auto-created.
public void serverBroadcast(String msg)
throws UnauthorizedException
MultiUserChatServer
serverBroadcast in interface MultiUserChatServermsg - The message to broadcast.
UnauthorizedExceptionpublic void setServiceName(String name)
MultiUserChatServer
setServiceName in interface MultiUserChatServername - The chat service name (host name).public void setKickIdleUsersTimeout(int timeout)
MultiUserChatServerTimerTask 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 MultiUserChatServer.setUserIdleTime(int).
setKickIdleUsersTimeout in interface MultiUserChatServertimeout - the time to elapse between clearing of idle chat users.public int getKickIdleUsersTimeout()
MultiUserChatServerMultiUserChatServer.getUserIdleTime().
getKickIdleUsersTimeout in interface MultiUserChatServerpublic void setUserIdleTime(int idleTime)
MultiUserChatServer
setUserIdleTime in interface MultiUserChatServeridleTime - the amount of time to wait before considering a user idle.public int getUserIdleTime()
MultiUserChatServer
getUserIdleTime in interface MultiUserChatServerpublic void setLogConversationsTimeout(int timeout)
MultiUserChatServerTimerTask 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 MultiUserChatServer.setLogConversationBatchSize(int).
setLogConversationsTimeout in interface MultiUserChatServertimeout - the time to elapse between logging the room conversations.public int getLogConversationsTimeout()
MultiUserChatServerTimerTask
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 MultiUserChatServer.getLogConversationBatchSize().
getLogConversationsTimeout in interface MultiUserChatServerpublic void setLogConversationBatchSize(int size)
MultiUserChatServer
setLogConversationBatchSize in interface MultiUserChatServersize - the number of messages to save to the database on each run of the logging process.public int getLogConversationBatchSize()
MultiUserChatServer
getLogConversationBatchSize in interface MultiUserChatServerpublic Collection<String> getUsersAllowedToCreate()
MultiUserChatServer
getUsersAllowedToCreate in interface MultiUserChatServerpublic Collection<String> getSysadmins()
MultiUserChatServer
getSysadmins in interface MultiUserChatServerpublic void addSysadmin(String userJID)
MultiUserChatServer
addSysadmin in interface MultiUserChatServeruserJID - the bare JID of the new user to add as a system administrator.public void removeSysadmin(String userJID)
MultiUserChatServer
removeSysadmin in interface MultiUserChatServeruserJID - the bare JID of the user to remove from the list.public boolean isAllowToDiscoverLockedRooms()
public void setAllowToDiscoverLockedRooms(boolean allowToDiscoverLockedRooms)
allowToDiscoverLockedRooms - if the service should provide information about locked
rooms.public boolean isRoomCreationRestricted()
MultiUserChatServergetUsersAllowedToCreate are allowed to create rooms.
isRoomCreationRestricted in interface MultiUserChatServerpublic void setRoomCreationRestricted(boolean roomCreationRestricted)
MultiUserChatServergetUsersAllowedToCreate are allowed to create rooms.
setRoomCreationRestricted in interface MultiUserChatServerroomCreationRestricted - whether anyone can create rooms or not.public void addUserAllowedToCreate(String userJID)
MultiUserChatServer
addUserAllowedToCreate in interface MultiUserChatServeruserJID - the bare JID of the new user to add to list.public void removeUserAllowedToCreate(String userJID)
MultiUserChatServer
removeUserAllowedToCreate in interface MultiUserChatServeruserJID - the bare JID of the user to remove from the list.public void initialize(XMPPServer server)
BasicModuleInitializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
initialize in interface Moduleinitialize in class BasicModuleserver - the server hosting this module.public void start()
BasicModuleStarts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
start in interface Modulestart in interface Componentstart in class BasicModulepublic void stop()
BasicModuleStops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
stop in interface Modulestop in class BasicModulepublic void enableService(boolean enabled)
MultiUserChatServer
enableService in interface MultiUserChatServerenabled - true if the service is enabled.public boolean isServiceEnabled()
MultiUserChatServerMultiUserChatServer.enableService(boolean) to
enable or disable the service.
isServiceEnabled in interface MultiUserChatServerpublic long getTotalChatTime()
MultiUserChatServer
getTotalChatTime in interface MultiUserChatServerpublic int getNumberChatRooms()
public int getNumberConnectedUsers()
public int getNumberRoomOccupants()
public void logConversation(MUCRoom room,
Message message,
JID sender)
MultiUserChatServerNote: 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 MultiUserChatServerroom - 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.wildfire.XMPPServer)public void messageBroadcastedTo(int numOccupants)
MultiUserChatServer
messageBroadcastedTo in interface MultiUserChatServernumOccupants - 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,
JID senderJID)
DiscoInfoProvider
getIdentities 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,
JID senderJID)
DiscoInfoProvider
getFeatures 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 XDataFormImpl getExtendedInfo(String name,
String node,
JID senderJID)
DiscoInfoProvider
getExtendedInfo 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 boolean hasInfo(String name,
String node,
JID senderJID)
DiscoInfoProvider
hasInfo 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<org.dom4j.Element> getItems(String name,
String node,
JID senderJID)
DiscoItemsProvider
getItems in interface DiscoItemsProvidername - the recipient JID's name.node - the requested disco node.senderJID - the XMPPAddress of user that sent the disco items request.
|
Wildfire 3.1.1 Javadoc | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||