public boolean sendMessageToUser(User toUser, String content) { PrivateChat chat = privateChats.get(toUser.getId()); if (chat == null) { chat = new PrivateChat(this, toUser); privateChats.put(toUser.getId(), chat); } Message message = new Message(content, new Date()); return chat.addMessage(message); }
public void addConversation(PrivateChat conversation) { User otherUser = conversation.getOtherParticipant(this); privateChats.put(otherUser.getId(), conversation); }