daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Apr 21st, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. List<HostedRoom> rooms = multiUserChatManager.getHostedRooms(groupChatService.asDomainBareJid());
  2.         for (HostedRoom room :
  3.                 rooms) {
  4.             if (room.getJid().getLocalpart().equals(groupChatRoomId)){
  5.                 multiUserChat = multiUserChatManager.getMultiUserChat(room.getJid());
  6.             }
  7.         }
  8.    
  9. if (multiUserChat != null) {
  10.             if (!multiUserChat.isJoined()) {
  11.                 multiUserChat.join(connection.getUser().getResourcepart());
  12.             }
  13.         }
  14.    
  15. public List<Message> getOldMessages() {
  16.     List<Message> oldMessages = new ArrayList<>();
  17.     try {
  18.         Message message = multiUserChat.nextMessage();
  19.  
  20.         while (message != null) {
  21.             oldMessages.add(message);
  22.             message = multiUserChat.nextMessage();
  23.         }
  24.     } catch (MultiUserChatException.MucNotJoinedException e) {
  25.         e.printStackTrace();
  26.     } catch (InterruptedException e) {
  27.         e.printStackTrace();
  28.     }
  29.     multiUserChat.addMessageListener(new MessageListener() {
  30.         @Override
  31.         public void processMessage(final Message message) {
  32.             listener.notifyMessage(message.getSubject(), message.getBody());
  33.  
  34.         }
  35.     });
  36.     return oldMessages;
  37. }
RAW Paste Data
Top