Create Chat Pattern

Hey all- one quick (or maybe not so quick) question:

Creating Chats- I’‘m building an app that uses Smack to in part as the foundation of a traditional chat engine. What’‘s the best way to kick off chat sessions? I’‘m thinking of two, and was hoping y’'all might point out the pros and cons of each:

Option 1:

Listen to a connection via PacketListener. When Message packets arrive, look up the send to see if there is a Chat already in progress. If not, create the Chat, else do nothing. (Problem: how do I pass the original message to the chat so that it shows up as the first line.)

Option 2:

Pre-create a Chat for every presentity on the roster, but leave them headless until the first message arrives, at which point show a chat window.

Thoughts?

Thanks,

Dan

Option 3:

Use the ChatManager to register a ChatManagerListener. This will notify you when a chat object is created either locally or remotely. Then, in that listener method attach a MessageListener to the newly created chat, which will get called whenever a new message arrives.

When a new chat is created you should cache it and then when you need to send a chat, try to use a cached one first, otherwise create a new one.

Chris

I like option 3! Thanks!

but the method in the chatManagerLister need a param ( type of Chat ), when chat created remotely,how to give this param?