Esempio n. 1
0
 public String getRoomFileStr(int idRoom) {
   if (maps.containsKey(idRoom)) {
     UserMap m = maps.get(idRoom);
     return m.getRoomFileStr();
   }
   return "";
 }
Esempio n. 2
0
 public int getIdFile(int idRoom) {
   if (maps.containsKey(idRoom)) {
     UserMap m = maps.get(idRoom);
     return m.getIdFile();
   }
   return -1;
 }
Esempio n. 3
0
 public int getNum(int idRoom) {
   if (maps.containsKey(idRoom)) {
     UserMap m = maps.get(idRoom);
     return m.getNum();
   } else {
     return 0;
   }
 }
Esempio n. 4
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;
   }
 }
Esempio n. 5
0
 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;
   }
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 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;
   }
 }
Esempio n. 8
0
 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;
   }
 }
Esempio n. 9
0
 public void setEnterFile(int idRoom, int idFile, String roomFileStr) {
   if (maps.containsKey(idRoom)) {
     UserMap m = maps.get(idRoom);
     m.setEnterFile(idFile, roomFileStr);
   }
 }