2
votes

How can we initialize MultiuserChat, these are the details, to create an object of MultiuserChat class we need the connection and room name as parameters // this is the constructor of MultiUserChat

  public MultiUserChat(Connection connection, String room) {
    this.connection = connection;
    this.room = room.toLowerCase();
    init();
}

its only applicable if we have a room ie. if we are inside a room. My question is if we are not inside the room, or we are not joined/created any rooms how can we initialize the MultiUserChat class. Because for adding listeners such as invitation rejection and addinvitationListener we need the object of the MultiUserChat.

eg. muc.addInvitationRejectionListener(new InvitationRejectionListener() {

            @Override
            public void invitationDeclined(String invitee, String reason) {
                Log.e("CHECK", "Invitation rejected, Inv- "+invitee+": Reas- "+reason);
                Toast.makeText(getApplicationContext()  , "Invtn REJECTED, invitee- "+invitee+" :reason-"+reason, 
                        Toast.LENGTH_LONG).show();

            }
        });
2
If anyone want to down vote the question please provide the reason.Jashan PJ
Did you ever figure this out? If so, can you share the details here?ekawas
sorry man, I don't have the work files, I think I made a solution for it. But I didn't remember. I will try to find it for you. Give me some time.Jashan PJ

2 Answers

0
votes

Your assumption is wrong. Creating a MultiUserChat instance does not make the client automatically join or create this MUC.

So simply create the instance and add the listeners.

-1
votes

You dont need an object of MultiUserChat for getting invitations. You can use below code.

MultiUserChat.addInvitationListener(conn3, new InvitationListener() {
public void invitationReceived(XMPPConnection conn, String room, String inviter,
String reason, String password) {

    // Reject the invitation

    MultiUserChat.decline(conn, room, inviter, "I'm busy right now");

    //Accept the invitation

    MultiUserChat muc=new MultiUserChat(conn,room);

    muc.join(testNickName,password);

}

}

For invitation rejection listener you need a MultiUserChat Object.