use of org.jivesoftware.xmpp.workgroup.AgentSession in project Openfire by igniterealtime.
the class TrackingProvider method executeSet.
public void executeSet(IQ packet, Workgroup workgroup) {
IQ reply = null;
Element iq = packet.getChildElement();
// Send back reply
reply = IQ.createResultIQ(packet);
workgroup.send(reply);
IQ update = new IQ();
Element elem = update.setChildElement("tracker", "http://jivesoftware.com/protocol/workgroup");
// Check if user is leaving.
Element leaving = iq.element("leaving");
if (leaving != null) {
elem.addElement("leaving").setText("true");
for (AgentSession session : workgroup.getAgentSessions()) {
update.setTo(session.getJID());
update.setType(IQ.Type.set);
workgroup.send(update);
}
return;
}
String url = iq.element("url").getTextTrim();
String title = iq.element("title").getTextTrim();
String referrer = iq.element("referrer").getTextTrim();
String uniqueID = iq.element("uniqueID").getTextTrim();
String ipAddress = iq.element("ipAddress").getTextTrim();
// Otherwise, notify of new user on site.
elem.addElement("url").setText(url);
elem.addElement("title").setText(title);
elem.addElement("referrer").setText(referrer);
elem.addElement("uniqueID").setText(uniqueID);
elem.addElement("ipAddress").setText(ipAddress);
for (AgentSession session : workgroup.getAgentSessions()) {
update.setTo(session.getJID());
update.setType(IQ.Type.set);
workgroup.send(update);
}
}
use of org.jivesoftware.xmpp.workgroup.AgentSession in project Openfire by igniterealtime.
the class SiteTracker method handleSiteUser.
private void handleSiteUser(IQ packet, Workgroup workgroup) {
IQ reply;
Element iq = packet.getChildElement();
// Define default values
IQ update = new IQ();
Element elem = update.setChildElement("site-user", "http://jivesoftware.com/protocol/workgroup");
String sessionID = iq.attribute("sessionID").getText();
elem.addAttribute("sessionID", sessionID);
// Check if a users session has expired
Element sessionExpired = iq.element("expired");
if (sessionExpired != null) {
siteUsers.remove(sessionID);
elem.addElement("sessionExpired").setText("true");
for (AgentSession session : workgroup.getAgentSessions()) {
update.setTo(session.getJID());
update.setType(IQ.Type.set);
workgroup.send(update);
}
reply = IQ.createResultIQ(packet);
workgroup.send(reply);
return;
}
Element chatting = iq.element("chatting");
if (chatting != null) {
elem.addElement("chatting").setText("true");
for (AgentSession session : workgroup.getAgentSessions()) {
update.setTo(session.getJID());
update.setType(IQ.Type.set);
workgroup.send(update);
}
reply = IQ.createResultIQ(packet);
workgroup.send(reply);
return;
}
// Check if user left a page
Element leaving = iq.element("leftPage");
if (leaving != null) {
elem.addElement("leftPage").setText("true");
for (AgentSession session : workgroup.getAgentSessions()) {
update.setTo(session.getJID());
update.setType(IQ.Type.set);
workgroup.send(update);
}
reply = IQ.createResultIQ(packet);
workgroup.send(reply);
// Handle pageView
SiteUser siteUser = siteUsers.get(sessionID);
if (siteUser != null) {
PageView lastView = siteUser.getLastView();
if (lastView != null) {
lastView.setEndTime(new Date());
}
}
return;
}
// If user has not left a page and the session has not expired. This user
// has entered a new page.
String url = iq.element("url").getTextTrim();
String title = iq.element("title").getTextTrim();
String referrer = iq.element("referrer").getTextTrim();
String ipAddress = iq.element("ipAddress").getTextTrim();
String userID = iq.element("userID").getTextTrim();
// Send back reply
reply = IQ.createResultIQ(packet);
workgroup.send(reply);
elem.addElement("url").setText(url);
elem.addElement("title").setText(title);
elem.addElement("referrer").setText(referrer);
elem.addElement("userID").setText(userID);
elem.addElement("ipAddress").setText(ipAddress);
// Add to tracking information
SiteUser siteUser = siteUsers.get(sessionID);
if (siteUser == null) {
siteUser = new SiteUser();
}
PageView pageView = new PageView();
pageView.setStartTime(new Date());
pageView.setTitle(title);
pageView.setUrl(url);
siteUser.addView(pageView);
siteUser.setJID(reply.getTo());
siteUsers.put(sessionID, siteUser);
for (AgentSession session : workgroup.getAgentSessions()) {
update.setTo(session.getJID());
update.setType(IQ.Type.set);
workgroup.send(update);
}
}
use of org.jivesoftware.xmpp.workgroup.AgentSession in project Openfire by igniterealtime.
the class ChatNotes method executeGet.
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply;
Element iq = packet.getChildElement();
// Verify that an agent is requesting this information.
try {
AgentSession agentSession = workgroup.getAgentManager().getAgentSession(packet.getFrom());
if (agentSession != null) {
String sessionID = iq.element("sessionID").getTextTrim();
sendNotesPacket(packet, workgroup, sessionID);
} else {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
}
} catch (AgentNotFoundException e) {
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(new PacketError(PacketError.Condition.item_not_found));
workgroup.send(reply);
}
}
use of org.jivesoftware.xmpp.workgroup.AgentSession in project Openfire by igniterealtime.
the class RoundRobinDispatcher method fillAgentsList.
/**
* <p>Generate the agents offer list.</p>
*/
private void fillAgentsList() {
AgentSessionList agentSessionList = queue.getAgentSessionList();
agentSessionList.addAgentSessionListener(this);
for (AgentSession agentSession : agentSessionList.getAgentSessions()) {
if (!agentList.contains(agentSession)) {
agentList.add(agentSession);
}
}
}
use of org.jivesoftware.xmpp.workgroup.AgentSession in project Openfire by igniterealtime.
the class InvitationRequest method execute.
public void execute() {
if (Type.user == type) {
AgentSession agentSession = null;
// Verify if the invitee user is an agent that is currently logged
try {
agentSession = WorkgroupManager.getInstance().getAgentManager().getAgent(invitee).getAgentSession();
} catch (AgentNotFoundException e) {
// Ignore
}
// Only Send muc invites to a particular user.
if (true) {
// Invitee is not an agent so send a standard MUC room invitation
sendMUCInvitiation();
// Keep track when the invitation was sent to the user
offerAccpeted = System.currentTimeMillis();
} else {
// Invite the agent to the room by sending an offer
Workgroup workgroup = agentSession.getWorkgroups().iterator().next();
RequestQueue requestQueue = workgroup.getRequestQueues().iterator().next();
// Add the requested agent as the initial target agent to get the offer
getMetaData().put("agent", Arrays.asList(invitee.toString()));
getMetaData().put("ignore", Arrays.asList(inviter.toBareJID()));
// Dispatch the request
requestQueue.getDispatcher().injectRequest(this);
}
} else if (Type.queue == type) {
// Send offer to the best again available in the requested queue
Workgroup targetWorkgroup = WorkgroupManager.getInstance().getWorkgroup(invitee.getNode());
if (targetWorkgroup == null) {
// No workgroup was found for the specified invitee. Send a Message with the error
sendErrorMessage("Specified workgroup was not found.");
return;
}
try {
RequestQueue requestQueue = targetWorkgroup.getRequestQueue(invitee.getResource());
getMetaData().put("ignore", Arrays.asList(inviter.toBareJID()));
// Dispatch the request
requestQueue.getDispatcher().injectRequest(this);
} catch (NotFoundException e) {
// No queue was found for the specified invitee. Send a Message with the error
sendErrorMessage("Specified queue was not found.");
}
} else if (Type.workgroup == type) {
// Select the best queue based on the original request
Workgroup targetWorkgroup = WorkgroupManager.getInstance().getWorkgroup(invitee.getNode());
if (targetWorkgroup != null) {
RequestQueue requestQueue = RoutingManager.getInstance().getBestQueue(targetWorkgroup, userRequest);
getMetaData().put("ignore", Arrays.asList(inviter.toBareJID()));
// Send offer to the best again available in the requested queue
requestQueue.getDispatcher().injectRequest(this);
} else {
// No workgroup was found for the specified invitee. Send a Message with the error
sendErrorMessage("Specified workgroup was not found.");
}
}
}
Aggregations