powered by Jive Software

ProcessMessage not called after certain time of calls

I am new to this smack api.I tried to develop a client using smack api from the tutors available online. It worked fine for me but after certain number of chats between two clients the processmessage method is not called.

Can anyone help me regarding this plz…

code goes here.

public void sendMessage(String message, String to) throws XMPPException

{

Chat chat = connection.getChatManager().createChat(to, this);

chat.sendMessage(message);

}

public void processMessage(Chat chat, Message message)

{

if(message.getType() == Message.Type.chat)

System.out.println(chat.getParticipant() + " says: " + message.getBody());

}

Thanks in advance

That is not enough information to tell what is going wrong.

But I will point out a few problems with your code. You are craeating a new chat every time you send a message instead of reusing the same one (for the same user). This is a leak as the Chat’s are stored in the ChatManager.

Thank u for this. I created a single instance of chat and now the problem is solved, but now what i get is a different issue.

Say i have two clients x and y, both are online and if x tries to send a chat message to y, the message is received but the process message is not called until y sends some message to x and after this first message from y everything works fine…

can u help me out plzzz…

Thanks in advance

You have to use a ChatManagerListener to learn of new Chat’s getting created when you receive a message. Smack makes a best guess to match the incoming message to an existing chat, which is what is happening after you create your own.

1 Like

Thanks a lot