public String createTopic(String topic) { if (!Topics.containsKey(topic)) { ServerChatRoom SCR = new ServerChatRoom(topic); SCR.startServer(nextPort++); Topics.put(topic, SCR); } return null; }
public Topics getTopics() { Topics allTopics = new Topics(); List<Topic> topicsList = new ArrayList<>(); topics .stream() .filter(t -> t.getType().equals("attached")) .forEach(t -> topicsList.addAll(t.getTopics())); allTopics.setTopics(topicsList); return allTopics; }
@Override public Chatroom joinTopic(String topic) { return Topics.get(topic); }