Search in sources :

Example 1 with PresenceManager

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);
                }
            }
        }
    }
}
Also used : JID(org.xmpp.packet.JID) Presence(org.xmpp.packet.Presence) CreateWorkgroup(org.jivesoftware.openfire.fastpath.commands.CreateWorkgroup) DeleteWorkgroup(org.jivesoftware.openfire.fastpath.commands.DeleteWorkgroup) PresenceManager(org.jivesoftware.openfire.PresenceManager)

Aggregations

PresenceManager (org.jivesoftware.openfire.PresenceManager)1 CreateWorkgroup (org.jivesoftware.openfire.fastpath.commands.CreateWorkgroup)1 DeleteWorkgroup (org.jivesoftware.openfire.fastpath.commands.DeleteWorkgroup)1 JID (org.xmpp.packet.JID)1 Presence (org.xmpp.packet.Presence)1