|
Openfire 3.3.3 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jivesoftware.openfire.container.BasicModule org.jivesoftware.openfire.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 |
addListener(MUCEventListener listener)
Registers a listener to receive events. |
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 |
removeListener(MUCEventListener listener)
Unregisters a listener to receive events. |
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.openfire.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 ChannelHandler
packet
- 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 Component
packet
- the packet.ComponentManager.sendPacket(Component, Packet)
public void initialize(JID jid, ComponentManager componentManager)
Component
The 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 Component
jid
- the XMPP address that this component is available at.componentManager
- the component manager.public void shutdown()
Component
shutdown
in interface Component
public String getServiceDomain()
MultiUserChatServer
getServiceDomain
in interface MultiUserChatServer
public JID getAddress()
RoutableChannelHandler
getAddress
in interface RoutableChannelHandler
public MUCRoom getChatRoom(String roomName, JID userjid) throws NotAllowedException
MultiUserChatServer
getChatRoom
in interface MultiUserChatServer
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)
MultiUserChatServer
getChatRoom
in interface MultiUserChatServer
roomName
- Name of the room to get.
public List<MUCRoom> getChatRooms()
MultiUserChatServer
getChatRooms
in interface MultiUserChatServer
public boolean hasChatRoom(String roomName)
MultiUserChatServer
hasChatRoom
in interface MultiUserChatServer
roomName
- the name of the chatroom to check.
public void removeChatRoom(String roomName)
MultiUserChatServer
removeChatRoom
in interface MultiUserChatServer
roomName
- The room to remove.public String getServiceName()
MultiUserChatServer
getServiceName
in interface MultiUserChatServer
public HistoryStrategy getHistoryStrategy()
MultiUserChatServer
getHistoryStrategy
in interface MultiUserChatServer
public void removeUser(JID jabberID)
MultiUserChatServer
removeUser
in interface MultiUserChatServer
jabberID
- The user's normal jid, not the chat nickname jid.public MUCUser getChatUser(JID userjid) throws UserNotFoundException
MultiUserChatServer
getChatUser
in interface MultiUserChatServer
userjid
- 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 MultiUserChatServer
msg
- The message to broadcast.
UnauthorizedException
public void setServiceName(String name)
MultiUserChatServer
setServiceName
in interface MultiUserChatServer
name
- The chat service name (host name).public void setKickIdleUsersTimeout(int timeout)
MultiUserChatServer
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 MultiUserChatServer.setUserIdleTime(int)
.
setKickIdleUsersTimeout
in interface MultiUserChatServer
timeout
- the time to elapse between clearing of idle chat users.public int getKickIdleUsersTimeout()
MultiUserChatServer
MultiUserChatServer.getUserIdleTime()
.
getKickIdleUsersTimeout
in interface MultiUserChatServer
public void setUserIdleTime(int idleTime)
MultiUserChatServer
setUserIdleTime
in interface MultiUserChatServer
idleTime
- the amount of time to wait before considering a user idle.public int getUserIdleTime()
MultiUserChatServer
getUserIdleTime
in interface MultiUserChatServer
public void setLogConversationsTimeout(int timeout)
MultiUserChatServer
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 MultiUserChatServer.setLogConversationBatchSize(int)
.
setLogConversationsTimeout
in interface MultiUserChatServer
timeout
- the time to elapse between logging the room conversations.public int getLogConversationsTimeout()
MultiUserChatServer
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 MultiUserChatServer.getLogConversationBatchSize()
.
getLogConversationsTimeout
in interface MultiUserChatServer
public void setLogConversationBatchSize(int size)
MultiUserChatServer
setLogConversationBatchSize
in interface MultiUserChatServer
size
- the number of messages to save to the database on each run of the logging process.public int getLogConversationBatchSize()
MultiUserChatServer
getLogConversationBatchSize
in interface MultiUserChatServer
public Collection<String> getUsersAllowedToCreate()
MultiUserChatServer
getUsersAllowedToCreate
in interface MultiUserChatServer
public Collection<String> getSysadmins()
MultiUserChatServer
getSysadmins
in interface MultiUserChatServer
public void addSysadmin(String userJID)
MultiUserChatServer
addSysadmin
in interface MultiUserChatServer
userJID
- the bare JID of the new user to add as a system administrator.public void removeSysadmin(String userJID)
MultiUserChatServer
removeSysadmin
in interface MultiUserChatServer
userJID
- 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()
MultiUserChatServer
getUsersAllowedToCreate
are allowed to create rooms.
isRoomCreationRestricted
in interface MultiUserChatServer
public void setRoomCreationRestricted(boolean roomCreationRestricted)
MultiUserChatServer
getUsersAllowedToCreate
are allowed to create rooms.
setRoomCreationRestricted
in interface MultiUserChatServer
roomCreationRestricted
- whether anyone can create rooms or not.public void addUserAllowedToCreate(String userJID)
MultiUserChatServer
addUserAllowedToCreate
in interface MultiUserChatServer
userJID
- the bare JID of the new user to add to list.public void removeUserAllowedToCreate(String userJID)
MultiUserChatServer
removeUserAllowedToCreate
in interface MultiUserChatServer
userJID
- the bare JID of the user to remove from the list.public void initialize(XMPPServer server)
BasicModule
Initializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
initialize
in interface Module
initialize
in class BasicModule
server
- the server hosting this module.public void start()
BasicModule
Starts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
start
in interface Module
start
in interface Component
start
in class BasicModule
public void stop()
BasicModule
Stops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
stop
in interface Module
stop
in class BasicModule
public void enableService(boolean enabled)
MultiUserChatServer
enableService
in interface MultiUserChatServer
enabled
- true if the service is enabled.public boolean isServiceEnabled()
MultiUserChatServer
MultiUserChatServer.enableService(boolean)
to
enable or disable the service.
isServiceEnabled
in interface MultiUserChatServer
public long getTotalChatTime()
MultiUserChatServer
getTotalChatTime
in interface MultiUserChatServer
public int getNumberChatRooms()
public int getNumberConnectedUsers()
public int getNumberRoomOccupants()
public void logConversation(MUCRoom room, Message message, JID sender)
MultiUserChatServer
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 MultiUserChatServer
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)
MultiUserChatServer
messageBroadcastedTo
in interface MultiUserChatServer
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, 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, 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 XDataFormImpl getExtendedInfo(String name, String node, 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 boolean hasInfo(String name, String node, 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<org.dom4j.Element> getItems(String name, String node, 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 void addListener(MUCEventListener listener)
MultiUserChatServer
addListener
in interface MultiUserChatServer
listener
- the listener.public void removeListener(MUCEventListener listener)
MultiUserChatServer
removeListener
in interface MultiUserChatServer
listener
- the listener.
|
Openfire 3.3.3 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |