use of org.jivesoftware.openfire.PresenceManager in project Openfire by igniterealtime.
the class WorkgroupManager method handleOutdatePresence.
/**
* Checks for outdated presences caused by network failures, etc.
*/
private void handleOutdatePresence() {
for (Workgroup workgroup : getWorkgroups()) {
for (AgentSession agentSession : workgroup.getAgentSessions()) {
final JID agentJID = agentSession.getJID();
final PresenceManager presenceManager = XMPPServer.getInstance().getPresenceManager();
boolean isOnline = false;
for (Presence presence : presenceManager.getPresences(agentJID.getNode())) {
if (presence.getFrom().equals(agentJID)) {
isOnline = true;
}
}
if (!isOnline) {
// Send offline presence to workgroup.
for (Workgroup wgroup : agentSession.getWorkgroups()) {
Presence presence = new Presence();
presence.setFrom(agentJID);
presence.setTo(wgroup.getJID());
presence.setType(Presence.Type.unavailable);
wgroup.getWorkgroupPresenceHandler().process(presence);
}
}
}
}
}
Aggregations