Question

I am trying the basics of setting up XMPP communication between android phones using aSmack. I have managed to register an account from my app and send messages to a Jabber-ID that I'm logged into on my PC. The issue is replies from my PC client don't seem to be getting received, the processMessage() in my MessageListener doesn't seem to be being called.

       try{connection.login("kmomochesstest", "password1");}
       catch(Exception e){Log.e("connection","Account login error: " + e.toString());}
       chat = connection.getChatManager().createChat("chesstestpc@macjabber.de", new MessageListener() {

             public void processMessage(Chat chat, Message message) {
                 try{System.out.println(message.getBody());}
             catch(Exception e){Log.e("connection","Message send error: " + e.toString());}
       });
       try{chat.sendMessage("Test Message from Activity");Log.d("connection","Just sent Message ");}
        catch(Exception e){Log.e("connection","Message send error: " + e.toString());}

At this point I'm trying to print to the console but I've tried printing to the Log and just echoing back to my PC with chat.sendMessage(message.getBody()). Nothing seems to register an incoming message. This seems to be the format on every how-to I've found online.

Était-ce utile?

La solution

What version of Smack are you using?

There was a problem in earlier versions when trying to match messages that did not contain thread ids to existing chats that were created with one (as Smack does). Pidgin, for instance does not use thread id's, which would in turn create a new chat instance when a message was received.

The matching process was improved in 3.2 to prevent this from happening.

Try creating a ChatManagerListener and see if you are getting new Chat's created from your replies.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top