1
votes

Can anybody tell me how to receive message in muc using Smack 4.1.0 rc1?

I am able to send message using below code.

Message message = new Message();
        message.setType(Message.Type.groupchat);
        message.setBody(strMessage);
        message.setTo(roomJid);
 multiUserChat.sendMessage(message);

I am using below code but not able to get the message.

    multiUserChat = multiUserChatManager.getMultiUserChat(roomJid);
    multiUserChat.addMessageListener(new MessageListener() {
        @Override
        public void processMessage(Message message) {
            Log.i(Constant.TAG, "processMessage");
        }
    }); 

My debugging is on and i can see that app is receiving message(D/SMACK( 6098): RECV (1): ) but listener is not getting called

3
Did you read Smack's MUC documentation?Flow
@Flow I already review it but i didn't find it. igniterealtime.org/builds/smack/docs/latest/documentation/…Hitendra
@Hitendra did you find solution? i already have this problem at this moment.Omid Zamani

3 Answers

0
votes

send presence / join to muc before adding message listener to the muc.

then you will get muc message into the listener.

without sending presence or join to the muc, you can not get the message into the listener but you can see in the logcat.

0
votes

I'm using stanza listener and able to receive MUC messages.

 final  StanzaListener stanzaListener = new StanzaListener() {
        @Override
        public void processStanza(Stanza packet) throws SmackException.NotConnectedException, InterruptedException {  .. }


xmppConnection.addAsyncStanzaListener(stanzaListener, StanzaTypeFilter.MESSAGE);