public synchronized boolean addChatroom(Chatroom chatroom) { checkNotNull(chatroom); if (isChatroomExisting(chatroom.getName())) return false; if (chatroom.getName().equals(defaultChatName)) return false; chatrooms.put(chatroom.getName(), chatroom); return true; }
public boolean renameChatroom(Chatroom chatroom, String newName) { checkNotNull(chatroom); checkNotNull(newName); if (isChatroomExisting(newName)) return false; if (newName.equals(defaultChatName)) return false; String oldName = chatroom.getName(); chatrooms.remove(oldName); chatrooms.put(newName, chatroom); return true; }
public synchronized boolean removeChatroom(Chatroom chatroom) { checkNotNull(chatroom); if (!isChatroomExisting(chatroom.getName())) return false; chatrooms.remove(chatroom.getName()); return true; }
void initServerData(int maxClients) { this.defaultChat = Chatroom.createDefault(defaultChatName, maxClients); this.chatrooms.put(defaultChatName, defaultChat); }