powered by Jive Software

Initial message lost when chat is created

hello,

i’m new to smack so excuse me if this is a silly question.

when a new message is arrived to smack, ChatManagerListener.chatCreated method is called however MessageListener.processMessage is not called. so i cannot reach the first message in chat sequence. I’m adding MessageListener at the point chat is created.

how to handle this situation ?

thanks in advance,

r a f t

below is the message sent from gaim to smack:

<message to="translator.bot@gmail.com/Smack4B4C3077" from="aptal.karga@gmail.com/Gaim13E2D651" type=“chat”>

<body>hello</body>

<x xmlns=“jabber:x:event”>

<composing/>

</x>

<html xmlns=“http://jabber.org/protocol/xhtml-im”>

&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;hello&lt;/body&gt;

</html>

<x xmlns=“google:nosave”/>

<record xmlns=“http://jabber.org/protocol/archive”/>

</message>

It should work the way you describe - add the listener before showing the message. I had a similar problem when I was adding synchronization (which wasn’t necessary at all). You might have some other timeconsuming thing going on that causes the packet to get lost so to say.

One thing to remember too is that the chat manager is using weak references to store chat objects, so as specified in the JavaDoc you must manually keep a reference to the chat object when it gets created otherwise it could be garbage collected before the message is processed. When a chat created callback is issued, I add the message listener and then put the chat into a hash map. I then receive a callback for the first message.

Chris

hi,

thanks for the answers. is turned out to be my code in ChatManagerListener.chatCreated was throwing an exception. sorry for false alarm.

i was adding the MessageListener before the exception was thrown. i guess smack will be better if it catches such user exceptions and prints information about them and more importantly continues executing smack code after the user exception is thrown

thanks,

r a f t