When client close,how to get the client username

hi:

 When client close,how to get the client username,and the openfire via which interface listening the client close.

I will make a plugin to implement clear the user roster cache when user client closing.

Any advice much appreciated.

Thanks!

I would try an SessionEventListener:

public void sessionDestroyed(Session session) {
    if (session instanceof ClientSession) {
        String username = session.getAddress().getNode();
        // ...
    }
}

I will make a plugin to implement clear the user roster cache when user client closing.
Why? Does this make sense?

Thank you! And I want to know how to get the session or clientsession when client closing.

As I said, take an SessionEventListener

Thank you very much! I got it.

 I have another question,I want writer a plugin to listen the client conversation,then add the contact data to oracle database for two user,and provider a interface for client to get the recent contact list,how to do it.

Thankyou!