AnsweredAssumed Answered

can't receive message from chat's listener

Question asked by cpacm on May 24, 2015

I'm useing smack4.1.1 in android with openfire 3.9.3

I create a Chat with ChatMessageListener

Chat newChat = ChatManager.getInstanceFor(connection).createChat(Jid,new ChatMessageListener() {
            public void processMessage(Chat chat, Message message) {
               XMPPLog.v("chat threadID:" + chat.getThreadID());
               XMPPLog.v("chat message:" + message.getBody());

then, I add a global listener

ChatManager.getInstanceFor(connection).addChatListener(new ChatManagerListener() {
   public void chatCreated(Chat chat, boolean createdLocally) {
      chat.addMessageListener(new ChatMessageListener() {
         public void processMessage(Chat chat, Message message) {   
            XMPPLog.v("Global chat threadID:" + chat.getThreadID());
            XMPPLog.v("Global chat message:" + message.getBody());

final,I sent a message and start receive message.

XMPPLog.v("send threadID:" + chat.getThreadID());
newChat.sentMessage("Hello,I'm cpacm");

but,why I can't receive message in chat's listener?


this is the log:

send threadID:434d00d5-020d-4c83-a1d9-e9abb3b640c4
Global chat threadID:4foBAP
Global chat message:hello,cpacm

here is XML:

<message to='cpacm2@' id='SGaK8-30' type='chat'><body>hello,I'm cpacm</body><thread>434d00d5-020d-4c83-a1d9-e9abb3b640c4</thread></message>
<message to='cpacm@' from='cpacm2@' id='1h8I8-107' type='chat'><body>hello,cpacm</body><thread>4foBAP</thread><x xmlns='jabber:x:event'><composing></composing><offline></offline></x></message>