Component needs to know when user is not online anymore


I have a component that manages user groups,

This component should be able to listen for “connection closed events” (say, a user closes the sparkweb browser window) and change the user group.

As it seems the components have no Roster, how can the component listen for connections closed ?



Hi Joao,

The best approach would be for your component to use a SessionEventListener to listen for sessionDestroyed events.

Hope that helps,


Tx Ryan!! perfect solution.

Heres my implementation in case its useful to anybody:

First coded the SessionEventListener interface implementation

package com.vilt.openfire.plugin;

import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.session.Session;

import org.jivesoftware.openfire.event.SessionEventListener;

public class ViltSessionEventListener implements SessionEventListener {

public void sessionDestroyed(Session session) {"A client session was DESTROYED:" + session.getAddress().toBareJID() );

public void anonymousSessionCreated(Session session) {"A client ANONYMOUS session was CREATED:" + session.getAddress().toBareJID() );

public void anonymousSessionDestroyed(Session session) {"A client ANONYMOUS session was destroyed:" + session.getAddress().toBareJID() );

public void resourceBound(Session session) {"Resource bound");

public void sessionCreated(Session session) {"A client session was CREATED:" + session.getAddress().toBareJID() );


Then added the listener to my Component/Plugin using the SessionEventDispatcher class ans passing a instance of my SessionEventListener implementation(inited in the component constructor)