We have using Wildfire 2.4.4 and smack 2.0.0 as server and client respectively. I have added a plugin which implements
SessionEventListener, and on sessionDestroyed() I call some custom DB request. In the same class I print a log off
message.
When I run my client and server locally the client is logged off immediately and I see logged off message from the
plugin.
Now when I move this to the production server, it takes couple of minutes for the server to know when the client logged
off.
The questions are: Has anyone run into this issue? Is there a better method to trigger a logoff at the server?
This is code for logout plugin.
package org.jivesoftware.wildfire.plugin;
Imports …
public class LogoutPlugin implements Plugin {
private ClientIDSessionEventListener listener = new ClientIDSessionEventListener();
public void initializePlugin(PluginManager manager, File pluginDirectory) {
SessionEventDispatcher.addListener(listener);
}
public void destroyPlugin() {
SessionEventDispatcher.removeListener(listener);
}
private class ClientIDSessionEventListener implements SessionEventListener {
public void sessionCreated(Session session) {
}
public void sessionDestroyed(Session session) {
String username = JID.unescapeNode(session.getAddress().getNode().toLowerCase());
System.out.println("username on logout - " + username);
try {
Properties prop = new Properties();
prop.load(new FileInputStream("…/conf/jive.properties"));
String ipaddress = prop.getProperty(“ipaddress”);
// Do some custom db part
System.out.println(sername + " logoff");
}
catch (MalformedURLException e) {
System.out.println("MalformedURLException = " + e);
}
catch (Exception e) {
System.out.println("Exception = " + e);
}
}
public void anonymousSessionCreated(Session session) {
}
public void anonymousSessionDestroyed(Session session) {
}
}
}