powered by Jive Software

processMessage not called

I have a strange situation, if I start chat from my device then it is not sending and receiving messages, altough in aSmack debug mode I see that xmpp message was send and also received on the other device, but processMessage was not called. But if I start the chat from the other device then it starts correctly and I can send or receive messages without problems. I am using aSmack 8.4.0.4

@Override

public void chatCreated(Chat chat, boolean createdLocally) {

if (isExistingChat(StringUtils.parseBareAddress(chat.getParticipant())) == null) {

mChats.add(chat);

mClient.get().communicationServiceClientMethod(Constants.CHAT_ADDED, chat);

if (!createdLocally) {

chat.addMessageListener(new MessageListener() {

@Override

public void processMessage(Chat chat, Message message) {

if (message != null && message.getBody() != null && message.getBody().length() > 0) {

message.setFrom(StringUtils.parseBareAddress(message.getFrom()));

XmppManager.getInstance(mContext).storeIncomingMessage(message);

mClient.get().communicationServiceClientMethod(Constants.MESSAGE_RECEIVED, new ChatMessage(message.getBody(), XmppManager.getInstance().getXmppRoster().getPerson(message.getFrom()) , new Date(), false, false));

}

}

});

}

}

}

public void sendMessage(String toUser, final ChatMessage chatMessage) {

Chat chat = isExistingChat(toUser);

XmppManager.getInstance(mContext).storeOutgoingMessage(toUser,chatMessage);

if (chat == null) {

chat = mChatManager.createChat(toUser, new MessageListener() {

public void processMessage(Chat chat, Message message) {

if (message != null && message.getBody() != null && message.getBody().length() > 0) {

message.setFrom(StringUtils.parseBareAddress(message.getFrom()));

XmppManager.getInstance(mContext).storeIncomingMessage(message);

mClient.get().communicationServiceClientMethod(Constants.MESSAGE_RECEIVED, new ChatMessage(message.getBody(), XmppManager.getInstance().getXmppRoster().getPerson(message.getFrom()),

new Date(), false, true, chatMessage.getFile()));

}

}

});

}

try {

if (chatMessage.getFile() != null) {

XmppManager.getInstance(mContext).getXmppFileTransferManager().sendFile(toUser, chatMessage.getFile(), chatMessage.getMessage());

} else {

chat.sendMessage(chatMessage.getMessage());

}

} catch (XMPPException e) {

System.out.println(“Error Delivering message”);

} catch (SmackException.NotConnectedException e) {

e.printStackTrace();

}

}

private Chat isExistingChat(String contact) {

contact = StringUtils.parseBareAddress(contact);

Chat result = null;

for (Chat entry : mChats) {

if (entry != null && StringUtils.parseBareAddress(entry.getParticipant()) != null && StringUtils.parseBareAddress(entry.getParticipant()).matches(contact)) {

result = entry;

break;

}

}

return result;