Exemplo n.º 1
0
 public static void deleteInactivePeers(int MAX_TIME_WITHOUT_UPDATES) {
   List toDelete = new ArrayList<Peer>();
   List<RealtimeRoom> roomsToSave = new ArrayList<RealtimeRoom>();
   // ++++++++= CLEAN ROOMs ++++++++++++++++++=
   Collection<RealtimeRoom> rooms = DbUtils.loadRooms();
   for (RealtimeRoom room : rooms) {
     List<Peer> roomPeers = room.getPeers();
     if (!roomPeers.isEmpty()) {
       for (Peer peer : roomPeers) {
         if (peer.getTimeSinceLastUpdate() >= RefreshCommand.MAX_TIME_WITHOUT_UPDATES) {
           toDelete.add(peer);
           roomsToSave.add(room);
           room.removePeer(peer.getId());
         }
       }
     } else {
       if (!room.isStatic() && !room.isWaitingRoom()) { // deletable room without peers
         toDelete.add(room);
       }
     }
   }
   ofy().delete().entities(toDelete);
   ofy().save().entities(roomsToSave);
   // LOGGER.info(inactivePeers.size() + " peers inativos deletados!");
 }
Exemplo n.º 2
0
 public static void tryCreateCurrenVersion() {
   Version v = getCurrentVersion();
   if (v == null || v.getMajorVersion() < 2) {
     DbUtils.save(Version.fromString("2.0.2"));
   }
 }