powered by Jive Software

XMPP MUCLight Implementation

android

#1

In XMPP service I connect to xmpp server, and once the connection is made I fetch all the groups that I am currently in, and add message listener to every group.

List<Jid> occupiedRooms = multiUserChatLightManager.getOccupiedRooms(JidCreate.domainBareFrom(ConstantXMPP.XMPPService.MUCLightService));
            for (Jid jid : occupiedRooms) {
                MultiUserChatLight multiUserChatLight = multiUserChatLightManager.getMultiUserChatLight(JidCreate.entityBareFrom(jid.toString()));
                MUCLightRoomConfiguration configuration = multiUserChatLight.getConfiguration();
                multiUserChatLight.addMessageListener(new org.jivesoftware.smack.MessageListener() {
                    @Override
                    public void processMessage(Message message) {
                        Log.e("Group message/n content", "" +  message.toXML());
                            if (message.getBody() != null && message.getBody().length() > 0) {
                                Log.e("Message Sender", message.getFrom().asBareJid().toString());
                                Log.e("Text Message", message.getBody());
                                handleGroupTextMessage(message);
                            }
                      }
                });
              }
    }

In service this is how i am adding listeners to the muclight room and i am getting messages when the chat activity is not open i.e, i get the messages when the user is in recent chat list activity, but as soon as i open the chat activity I don’t receive any packet or message,

addMessageListener method actually put the message listener into

Set<MessageListener> messageListeners = new    CopyOnWriteArraySet<MessageListener>();

so it is like handling all the listeners for each and every group, but still i cannot make this thing work

@Paul_Schaub @Flow


#2

The field is not static, is it?


#3

No it is not static, at a instance when my chat activity is not open, i am receiving the messages