I’‘m developing a small instant messenger app. I have a listener for incomming messages. Once a message arrives, I’'m checking the thread id of the chat and send the message to the appropriate Conversation (a Object to store messages, the observable for the Chat gui). I also store chat Objects, If the chat object does not yet exist on the arrival fo a message, I create it and store it with the same thread id as the incomming message, so i have control which message goes to which conversation. BUT: When i create the chat object, I need to supply it with the user… so I thought i could take the From parameter from the incomming message, but the format is different:
Message From: largo@blue/Smack
What i Need: largo@blue
Am I going the wrong way with my app? Can I process these messages somehow differently?
Note that there’'s a difference between contacts on the roster and contacts that are online. You will always chat with a jid that contains a resource, so it might be a good idea to store the resource along with the ongoing chat.
In my client, there’‘s a hierarchy: The contacts on the roster don’‘t have a presence state, but they can contain other items that are online and have a presence. This way I can even chat to both blah@blah.com/Smack1 and blah@blah.com/Smack2 at the same time, and they don’'t interfere.