1
votes

I am using aSmack library for creating Group Chat ( MultiUserChat) in android. able to create MultiUserChat instance, getting available rooms in that domain and able to join in a perticular room. Now i have some question on this, those are

  1. Is it required to maintain same instance for MUC in throughout application ?
  2. How to get last 20 discussion history of a particular room ?

now i try like this to get discussion history

DiscussionHistory history = new DiscussionHistory();
history.setMaxStanzas(20);               
muc2.join(acc_id, null, history, JOIN_TIMEOUT); 
Message oldMsg = muc2.nextMessage(1000);

By using above code now i am getting only one message from server that is also first message available in the history. But my requirement is i want to get all the last 20 messages available in the discussion history of a room.

Anybody help me on this issue's...

1
I am also facing same issue.. any solution fro this @RajaReddyMr. N.V.Rao

1 Answers

0
votes

Try this code

new Thread(new Runnable() {
  @Override
  public void run() {
    do{
       Message oldMsg = muc.nextMessage();
        if(oldMsg.getBody()!=null){
          //GetMessage(oldMsg); 
        }else{
           break;
        }
   }while(true);
  }
}).start();