public String getRoomFileStr(int idRoom) { if (maps.containsKey(idRoom)) { UserMap m = maps.get(idRoom); return m.getRoomFileStr(); } return ""; }
public int getIdFile(int idRoom) { if (maps.containsKey(idRoom)) { UserMap m = maps.get(idRoom); return m.getIdFile(); } return -1; }
public int getNum(int idRoom) { if (maps.containsKey(idRoom)) { UserMap m = maps.get(idRoom); return m.getNum(); } else { return 0; } }
public boolean sendUserMessage(int idRoom, String username, String message) throws IOException { if (maps.containsKey(idRoom)) { UserMap m = maps.get(idRoom); return m.sendUserMassage(username, message); } else { return false; } }
public boolean broadcast(int idRoom, String message, FcMessageInbound current) throws IOException { if (maps.containsKey(idRoom)) { UserMap m = maps.get(idRoom); m.broadcast(message, current); return true; } else { return false; } }
public boolean firstLoginRoom(int idRoom, String username, FcMessageInbound fmi) throws IOException { // System.out.println(maps.containsKey(idRoom)); if (!maps.containsKey(idRoom)) { maps.put(idRoom, new UserMap()); System.out.println("Room " + idRoom + " opened;"); System.out.println("user " + username + " enter Room " + idRoom + ";"); // System.out.println(maps.containsKey(idRoom)); UserMap m = maps.get(idRoom); return m.insertUser(username, fmi); } return false; }
public boolean loginRoom(int idRoom, String username, FcMessageInbound fmi) throws IOException { // System.out.println(maps.containsKey(idRoom)); if (maps.containsKey(idRoom)) { UserMap m = maps.get(idRoom); System.out.println("user " + username + " enter Room " + idRoom + ";"); requestPic rp = new requestPic(); rp.setFrom(username); rp.setUsage("updatePic"); randomSend(idRoom, gson.toJson(rp)); return m.insertUser(username, fmi); } else { return false; } }
public boolean logoutRoom(int idRoom, String username) throws IOException { if (maps.containsKey(idRoom)) { UserMap m = maps.get(idRoom); boolean result = m.quitUser(username); System.out.println("user " + username + " leave Room " + idRoom + ";"); if (result) { if (m.isEmpty()) { return closeRoom(idRoom); } else { return true; } } else { return false; } } else { return false; } }
public void setEnterFile(int idRoom, int idFile, String roomFileStr) { if (maps.containsKey(idRoom)) { UserMap m = maps.get(idRoom); m.setEnterFile(idFile, roomFileStr); } }