4

I have the following code to listen for invitations to a chatroom:

    Connection.DEBUG_ENABLED = true;
    XMPPConnection connection = new XMPPConnection("jabber.org");
    connection.connect();
    connection.login("username", "password");

    MultiUserChat.addInvitationListener(connection, new InvitationListener() {
        @Override
        public void invitationReceived(Connection arg0, String arg1,
                String arg2, String arg3, String arg4, Message arg5) {
            System.out.println("Invitation Received!");
        }
    });

    System.out.println("Connected, waiting for invitation");
    while(true) {
        Thread.yield();
    }
}

I then use another account to login with pidgin create a chatroom, and invite the above user. The invitationReceived method is not called. The smack debugger receives a presence update when I login, but no other packets. However, if I am logged in to the above user with pidgin, I do receive the invitation. How can I make smack detect the invitation request?

Jonathan Pullano
  • 322
  • 2
  • 13
  • Hi Jonathan are u able to receive an invitation i mean your invitationReceived method is calling ... ?? I was able to invite a user but not able to receive any invitations .. – KK_07k11A0585 Nov 01 '13 at 12:34

2 Answers2

2

I might be too late to answer this question ,but i would like to share my solution here, i had same issue ,

First off all it depends what version of smack are you using(i recommended latest version)

Second, user sending MUC invitation and user receiving invitation should be connected to same server in order to receive MUC invitation.

Third always enable smack debugger ,it will give information about incoming and outgoing stanza.

Fourth factor you should consider is to send a presence to XMPP server after login as shown below,

       connection.setStatus(true,"ONLINE");

public void setStatus(boolean available, String status) throws XMPPException {
        Presence.Type type = available? Type.available: Type.unavailable;
        Presence presence = new Presence(type);
        presence.setStatus(status);
        connection.sendPacket(presence);
    } 

sending presence informs xmpp server about user status and then presence information as well as new invitation will be received if you have enabled listener on connection object ,this works for me hope it will works for you also,please correct me if any information is wrong.

Dev
  • 2,326
  • 24
  • 45
0

You might be using the wrong username from pidgin. You have to use the name followed by the email address.

colegu
  • 370
  • 2
  • 12