powered by Jive Software

Chat management in Smack

I’m new to Smack, and I’m having a bit of trouble understanding how to manage multiple chats and inbound messages. I’m not sure how to set up filters, listeners, collectors properly for my needs. I want to be able to receive anything sent to me. And I want to be able to respond, obviously. But I’m confused by the statefulness of chat objects. They have their own listeners, and you seem to need them in order to send messages. So how do you partition inbound messages so that the ones on open chats go to the open chat, while the ones not on open chats get processed by a general listener (which presumably opens a new chat)?

I’m currently using a ToContainsFilter to grab everything sent to me. When I receive something, I believe I have to create a chat in order to reply. So, I tried creating a new chat and setting up a listener for that chat, hoping that the chat listener would receive from then on, instead of the generic listener. But it doesn’t. The generic listener still gets everything.

So, how do I make sure that I can listen for anything sent to me and still maintain open chats?

I hope that question is clear. Thanks for any guidance, including a pointer to a doc that might make this clear.

Thanks!