Suggestions on how to handle messages sent to a user no longer online?


This is what I want:

When two users are talking to one another, and one user goes offline, I want the message the online user sent to be dropped, and a message appear stating that the user he/she was talking to went offline.

I understand that the Smack server has several options for handling offline messages, one being able to bounce back the sent message. Now I was thinking I could do some sort of compareTo to check if the received message was the same as the one recently sent, but that seems like a hack. Can you guys suggest better ways in checking if a user went offline?

I implemented this by having all my chat windows watch out for presence changes. So if I was chatting to someone and they went offline my chat window object would get notified of the event.

I found the best way to implement this was to use the Observer pattern. PM for me info if you like