@Override public List<String> getPendingChatRoomUser() { updateSessionManager(); String user = getThreadLocalRequest().getRemoteUser(); List<String> pendingRooms = new ArrayList<String>(); if (user != null) { int countCycle = 0; // Persistence connection = DELAY * CYCLES do { pendingRooms = manager.getPendingChatRoomUser(user); countCycle++; try { Thread.sleep(DELAY); } catch (InterruptedException e) { // Ignore } } while (pendingRooms.isEmpty() && (countCycle < CYCLES) && manager.getLoggedUsers().contains(user)); } return pendingRooms; }
@Override public List<String> getPendingMessage(String room) throws OKMException { updateSessionManager(); String user = getThreadLocalRequest().getRemoteUser(); List<String> pendingMessages = new ArrayList<String>(); try { if (user != null) { int countCycle = 0; // Persistence connection = DELAY * CYCLES do { pendingMessages = manager.getPendingMessage(user, room); countCycle++; try { Thread.sleep(DELAY); } catch (InterruptedException e) { // Ignore } } while (pendingMessages.isEmpty() && (countCycle < CYCLES) && manager.getLoggedUsers().contains(user)); } } catch (PrincipalAdapterException e) { log.error(e.getMessage(), e); throw new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMChatService, ErrorCode.CAUSE_PrincipalAdapter), e.getMessage()); } return pendingMessages; }
@Override public List<GWTUser> getLoggedUsers() throws OKMException { List<GWTUser> users = new ArrayList<GWTUser>(); updateSessionManager(); try { for (String userId : manager.getLoggedUsers()) { GWTUser user = new GWTUser(); user.setId(userId); user.setUsername(OKMAuth.getInstance().getName(null, userId)); users.add(user); } } catch (PrincipalAdapterException e) { log.error(e.getMessage(), e); throw new OKMException( ErrorCode.get(ErrorCode.ORIGIN_OKMChatService, ErrorCode.CAUSE_PrincipalAdapter), e.getMessage()); } return users; }