Commit bfd0b0c0 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added #getChatRooms() to get all the rooms within the service.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@454 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3bb95cb6
......@@ -130,6 +130,14 @@ public interface MultiUserChatServer {
*/
MUCRoom getChatRoom(String roomName);
/**
* Retuns a list with a snapshot of all the rooms in the server (i.e. persistent or not,
* in memory or not).
*
* @return a list with a snapshot of all the rooms.
*/
List<MUCRoom> getChatRooms();
/**
* Returns true if the server includes a chatroom with the requested name.
*
......
......@@ -312,6 +312,20 @@ public class MultiUserChatServerImpl extends BasicModule implements MultiUserCha
return answer;
}
public List<MUCRoom> getChatRooms() {
List<MUCRoom> answer = new ArrayList<MUCRoom>(rooms.size() * 2);
synchronized (rooms) {
answer.addAll(rooms.values());
synchronized (persistentRoomSurrogateCache) {
if (persistentRoomSurrogateCache.size() == 0) {
populateRoomSurrogateCache();
}
}
answer.addAll(persistentRoomSurrogateCache.values());
}
return answer;
}
private void populateRoomSurrogateCache() {
for (MUCRoom room : MUCPersistenceManager.getRoomSurrogates(this, router)) {
persistentRoomSurrogateCache.put(room.getName(), room);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment