/** * Sets the agent's current status with the workgroup. The presence mode affects how offers * are routed to the agent. The possible presence modes with their meanings are as follows:<ul> * <p/> * <li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more chats * (equivalent to Presence.Mode.CHAT). * <li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be disturbed. * However, special case, or extreme urgency chats may still be offered to the agent. * <li>Presence.Mode.AWAY -- the agent is not available and should not * have a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY).</ul> * * @param presenceMode the presence mode of the agent. * @param status sets the status message of the presence update. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws IllegalStateException if the agent is not online with the workgroup. */ public void setStatus(Presence.Mode presenceMode, String status) throws NoResponseException, XMPPErrorException, NotConnectedException { if (!online) { throw new IllegalStateException("Cannot set status when the agent is not online."); } if (presenceMode == null) { presenceMode = Presence.Mode.available; } this.presenceMode = presenceMode; Presence presence = new Presence(Presence.Type.available); presence.setMode(presenceMode); presence.setTo(this.getWorkgroupJID()); if (status != null) { presence.setStatus(status); } presence.addExtension(new MetaData(this.metaData)); PacketCollector collector = this.connection.createPacketCollectorAndSend(new AndFilter(new StanzaTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)), presence); collector.nextResultOrThrow(); }
private Message getMessage(String messageText, RequestUtils util, boolean transfer) { Map metadata = new HashMap(); metadata.put("messageText", messageText); metadata.put("username", util.getUsername()); metadata.put("userID", util.getUserID()); metadata.put("transfer", Boolean.toString(transfer)); metadata.put("question", util.getQuestion()); metadata.put("email", util.getEmailAddress()); metadata.put("workgroup", util.getWorkgroup()); if (ModelUtil.hasLength(util.getRequestLocation())) { metadata.put("Location", util.getRequestLocation()); } // Add Metadata as message extension final MetaData data = new MetaData(metadata); Message message = new Message(); message.addExtension(data); return message; }
/** * Sets the agent's current status with the workgroup. The presence mode affects how offers * are routed to the agent. The possible presence modes with their meanings are as follows:<ul> * <p/> * <li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more chats * (equivalent to Presence.Mode.CHAT). * <li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be disturbed. * However, special case, or extreme urgency chats may still be offered to the agent. * <li>Presence.Mode.AWAY -- the agent is not available and should not * have a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY).</ul> * <p/> * The max chats value is the maximum number of chats the agent is willing to have routed to * them at once. Some servers may be configured to only accept max chat values in a certain * range; for example, between two and five. In that case, the maxChats value the agent sends * may be adjusted by the server to a value within that range. * * @param presenceMode the presence mode of the agent. * @param maxChats the maximum number of chats the agent is willing to accept. * @param status sets the status message of the presence update. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws IllegalStateException if the agent is not online with the workgroup. */ public void setStatus(Presence.Mode presenceMode, int maxChats, String status) throws NoResponseException, XMPPErrorException, NotConnectedException { if (!online) { throw new IllegalStateException("Cannot set status when the agent is not online."); } if (presenceMode == null) { presenceMode = Presence.Mode.available; } this.presenceMode = presenceMode; this.maxChats = maxChats; Presence presence = new Presence(Presence.Type.available); presence.setMode(presenceMode); presence.setTo(this.getWorkgroupJID()); if (status != null) { presence.setStatus(status); } // Send information about max chats and current chats as a packet extension. DefaultExtensionElement agentStatus = new DefaultExtensionElement(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE); agentStatus.setValue("max-chats", "" + maxChats); presence.addExtension(agentStatus); presence.addExtension(new MetaData(this.metaData)); PacketCollector collector = this.connection.createPacketCollectorAndSend(new AndFilter( new StanzaTypeFilter(Presence.class), FromMatchesFilter.create(workgroupJID)), presence); collector.nextResultOrThrow(); }
/** * Sets the agent's current status with the workgroup. The presence mode affects how offers * are routed to the agent. The possible presence modes with their meanings are as follows:<ul> * <p/> * <li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more chats * (equivalent to Presence.Mode.CHAT). * <li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be disturbed. * However, special case, or extreme urgency chats may still be offered to the agent. * <li>Presence.Mode.AWAY -- the agent is not available and should not * have a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY).</ul> * * @param presenceMode the presence mode of the agent. * @param status sets the status message of the presence update. * @throws XMPPException if an error occurs setting the agent status. * @throws IllegalStateException if the agent is not online with the workgroup. */ public void setStatus(Presence.Mode presenceMode, String status) throws XMPPException { if (!online) { throw new IllegalStateException("Cannot set status when the agent is not online."); } if (presenceMode == null) { presenceMode = Presence.Mode.available; } this.presenceMode = presenceMode; Presence presence = new Presence(Presence.Type.available); presence.setMode(presenceMode); presence.setTo(this.getWorkgroupJID()); if (status != null) { presence.setStatus(status); } presence.addExtension(new MetaData(this.metaData)); PacketCollector collector = this.connection.createPacketCollector(new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(workgroupJID))); this.connection.sendPacket(presence); presence = (Presence)collector.nextResult(5000); collector.cancel(); if (!presence.isAvailable()) { throw new XMPPException("No response from server on status set."); } if (presence.getError() != null) { throw new XMPPException(presence.getError()); } }
/** * PacketExtensionProvider implementation */ public PacketExtension parseExtension (XmlPullParser parser) throws Exception { Map metaData = MetaDataUtils.parseMetaData(parser); return new MetaData(metaData); }
/** * PacketExtensionProvider implementation */ public PacketExtension parseExtension (XmlPullParser parser) throws Exception { Map<String, List<String>> metaData = MetaDataUtils.parseMetaData(parser); return new MetaData(metaData); }
/** * Sets the agent's current status with the workgroup. The presence mode * affects how offers are routed to the agent. The possible presence modes * with their meanings are as follows: * <ul> * <p/> * <li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more * chats (equivalent to Presence.Mode.CHAT). * <li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be * disturbed. However, special case, or extreme urgency chats may still be * offered to the agent. * <li>Presence.Mode.AWAY -- the agent is not available and should not have * a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY). * </ul> * * @param presenceMode * the presence mode of the agent. * @param status * sets the status message of the presence update. * @throws XMPPException * if an error occurs setting the agent status. * @throws IllegalStateException * if the agent is not online with the workgroup. */ public void setStatus(Presence.Mode presenceMode, String status) throws XMPPException { if (!online) { throw new IllegalStateException( "Cannot set status when the agent is not online."); } if (presenceMode == null) { presenceMode = Presence.Mode.available; } this.presenceMode = presenceMode; Presence presence = new Presence(Presence.Type.available); presence.setMode(presenceMode); presence.setTo(this.getWorkgroupJID()); if (status != null) { presence.setStatus(status); } presence.addExtension(new MetaData(this.metaData)); PacketCollector collector = this.connection .createPacketCollector(new AndFilter(new PacketTypeFilter( Presence.class), new FromContainsFilter(workgroupJID))); this.connection.sendPacket(presence); presence = (Presence) collector.nextResult(5000); collector.cancel(); if (!presence.isAvailable()) { throw new XMPPException("No response from server on status set."); } if (presence.getError() != null) { throw new XMPPException(presence.getError()); } }
/** * PacketExtensionProvider implementation */ public PacketExtension parseExtension(XmlPullParser parser) throws Exception { Map metaData = MetaDataUtils.parseMetaData(parser); return new MetaData(metaData); }
private void handlePacket(Stanza packet) { if (packet instanceof Message) { Message msg = (Message)packet; // Check to see if the user left the queue. ExtensionElement pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup"); ExtensionElement queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup"); if (pe != null) { fireQueueDepartedEvent(); } else if (queueStatus != null) { QueueUpdate queueUpdate = (QueueUpdate)queueStatus; if (queueUpdate.getPosition() != -1) { fireQueuePositionEvent(queueUpdate.getPosition()); } if (queueUpdate.getRemaingTime() != -1) { fireQueueTimeEvent(queueUpdate.getRemaingTime()); } } else { // Check if a room invitation was sent and if the sender is the workgroup MUCUser mucUser = (MUCUser)msg.getExtension("x", "http://jabber.org/protocol/muc#user"); MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null; if (invite != null && workgroupJID.equals(invite.getFrom())) { String sessionID = null; Map<String, List<String>> metaData = null; pe = msg.getExtension(SessionID.ELEMENT_NAME, SessionID.NAMESPACE); if (pe != null) { sessionID = ((SessionID)pe).getSessionID(); } pe = msg.getExtension(MetaData.ELEMENT_NAME, MetaData.NAMESPACE); if (pe != null) { metaData = ((MetaData)pe).getMetaData(); } WorkgroupInvitation inv = new WorkgroupInvitation(connection.getUser(), msg.getFrom(), workgroupJID, sessionID, msg.getBody(), msg.getFrom(), metaData); fireInvitationEvent(inv); } } } }
/** * PacketExtensionProvider implementation * @throws IOException * @throws XmlPullParserException */ public MetaData parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { Map<String, List<String>> metaData = MetaDataUtils.parseMetaData(parser); return new MetaData(metaData); }
/** * Sets the agent's current status with the workgroup. The presence mode affects how offers * are routed to the agent. The possible presence modes with their meanings are as follows:<ul> * <p/> * <li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more chats * (equivalent to Presence.Mode.CHAT). * <li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be disturbed. * However, special case, or extreme urgency chats may still be offered to the agent. * <li>Presence.Mode.AWAY -- the agent is not available and should not * have a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY).</ul> * <p/> * The max chats value is the maximum number of chats the agent is willing to have routed to * them at once. Some servers may be configured to only accept max chat values in a certain * range; for example, between two and five. In that case, the maxChats value the agent sends * may be adjusted by the server to a value within that range. * * @param presenceMode the presence mode of the agent. * @param maxChats the maximum number of chats the agent is willing to accept. * @param status sets the status message of the presence update. * @throws XMPPException if an error occurs setting the agent status. * @throws IllegalStateException if the agent is not online with the workgroup. */ public void setStatus(Presence.Mode presenceMode, int maxChats, String status) throws XMPPException { if (!online) { throw new IllegalStateException("Cannot set status when the agent is not online."); } if (presenceMode == null) { presenceMode = Presence.Mode.available; } this.presenceMode = presenceMode; this.maxChats = maxChats; Presence presence = new Presence(Presence.Type.available); presence.setMode(presenceMode); presence.setTo(this.getWorkgroupJID()); if (status != null) { presence.setStatus(status); } // Send information about max chats and current chats as a packet extension. DefaultPacketExtension agentStatus = new DefaultPacketExtension(AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE); agentStatus.setValue("max-chats", "" + maxChats); presence.addExtension(agentStatus); presence.addExtension(new MetaData(this.metaData)); PacketCollector collector = this.connection.createPacketCollector(new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(workgroupJID))); this.connection.sendPacket(presence); presence = (Presence)collector.nextResult(5000); collector.cancel(); if (!presence.isAvailable()) { throw new XMPPException("No response from server on status set."); } if (presence.getError() != null) { throw new XMPPException(presence.getError()); } }
private void handlePacket(Packet packet) { if (packet instanceof Message) { Message msg = (Message)packet; // Check to see if the user left the queue. PacketExtension pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup"); PacketExtension queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup"); if (pe != null) { fireQueueDepartedEvent(); } else if (queueStatus != null) { QueueUpdate queueUpdate = (QueueUpdate)queueStatus; if (queueUpdate.getPosition() != -1) { fireQueuePositionEvent(queueUpdate.getPosition()); } if (queueUpdate.getRemaingTime() != -1) { fireQueueTimeEvent(queueUpdate.getRemaingTime()); } } else { // Check if a room invitation was sent and if the sender is the workgroup MUCUser mucUser = (MUCUser)msg.getExtension("x", "http://jabber.org/protocol/muc#user"); MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null; if (invite != null && workgroupJID.equals(invite.getFrom())) { String sessionID = null; Map metaData = null; pe = msg.getExtension(SessionID.ELEMENT_NAME, SessionID.NAMESPACE); if (pe != null) { sessionID = ((SessionID)pe).getSessionID(); } pe = msg.getExtension(MetaData.ELEMENT_NAME, MetaData.NAMESPACE); if (pe != null) { metaData = ((MetaData)pe).getMetaData(); } WorkgroupInvitation inv = new WorkgroupInvitation(connection.getUser(), msg.getFrom(), workgroupJID, sessionID, msg.getBody(), msg.getFrom(), metaData); fireInvitationEvent(inv); } } } }
private void handlePacket(Packet packet) { if (packet instanceof Message) { Message msg = (Message)packet; // Check to see if the user left the queue. PacketExtension pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup"); PacketExtension queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup"); if (pe != null) { fireQueueDepartedEvent(); } else if (queueStatus != null) { QueueUpdate queueUpdate = (QueueUpdate)queueStatus; if (queueUpdate.getPosition() != -1) { fireQueuePositionEvent(queueUpdate.getPosition()); } if (queueUpdate.getRemaingTime() != -1) { fireQueueTimeEvent(queueUpdate.getRemaingTime()); } } else { // Check if a room invitation was sent and if the sender is the workgroup MUCUser mucUser = (MUCUser)msg.getExtension("x", "http://jabber.org/protocol/muc#user"); MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null; if (invite != null && workgroupJID.equals(invite.getFrom())) { String sessionID = null; Map<String, List<String>> metaData = null; pe = msg.getExtension(SessionID.ELEMENT_NAME, SessionID.NAMESPACE); if (pe != null) { sessionID = ((SessionID)pe).getSessionID(); } pe = msg.getExtension(MetaData.ELEMENT_NAME, MetaData.NAMESPACE); if (pe != null) { metaData = ((MetaData)pe).getMetaData(); } WorkgroupInvitation inv = new WorkgroupInvitation(connection.getUser(), msg.getFrom(), workgroupJID, sessionID, msg.getBody(), msg.getFrom(), metaData); fireInvitationEvent(inv); } } } }
/** * Sets the agent's current status with the workgroup. The presence mode * affects how offers are routed to the agent. The possible presence modes * with their meanings are as follows: * <ul> * <p/> * <li>Presence.Mode.AVAILABLE -- (Default) the agent is available for more * chats (equivalent to Presence.Mode.CHAT). * <li>Presence.Mode.DO_NOT_DISTURB -- the agent is busy and should not be * disturbed. However, special case, or extreme urgency chats may still be * offered to the agent. * <li>Presence.Mode.AWAY -- the agent is not available and should not have * a chat routed to them (equivalent to Presence.Mode.EXTENDED_AWAY). * </ul> * <p/> * The max chats value is the maximum number of chats the agent is willing * to have routed to them at once. Some servers may be configured to only * accept max chat values in a certain range; for example, between two and * five. In that case, the maxChats value the agent sends may be adjusted by * the server to a value within that range. * * @param presenceMode * the presence mode of the agent. * @param maxChats * the maximum number of chats the agent is willing to accept. * @param status * sets the status message of the presence update. * @throws XMPPException * if an error occurs setting the agent status. * @throws IllegalStateException * if the agent is not online with the workgroup. */ public void setStatus(Presence.Mode presenceMode, int maxChats, String status) throws XMPPException { if (!online) { throw new IllegalStateException( "Cannot set status when the agent is not online."); } if (presenceMode == null) { presenceMode = Presence.Mode.available; } this.presenceMode = presenceMode; this.maxChats = maxChats; Presence presence = new Presence(Presence.Type.available); presence.setMode(presenceMode); presence.setTo(this.getWorkgroupJID()); if (status != null) { presence.setStatus(status); } // Send information about max chats and current chats as a packet // extension. DefaultPacketExtension agentStatus = new DefaultPacketExtension( AgentStatus.ELEMENT_NAME, AgentStatus.NAMESPACE); agentStatus.setValue("max-chats", "" + maxChats); presence.addExtension(agentStatus); presence.addExtension(new MetaData(this.metaData)); PacketCollector collector = this.connection .createPacketCollector(new AndFilter(new PacketTypeFilter( Presence.class), new FromContainsFilter(workgroupJID))); this.connection.sendPacket(presence); presence = (Presence) collector.nextResult(5000); collector.cancel(); if (!presence.isAvailable()) { throw new XMPPException("No response from server on status set."); } if (presence.getError() != null) { throw new XMPPException(presence.getError()); } }
private void handlePacket(Packet packet) { if (packet instanceof Message) { Message msg = (Message) packet; // Check to see if the user left the queue. PacketExtension pe = msg.getExtension("depart-queue", "http://jabber.org/protocol/workgroup"); PacketExtension queueStatus = msg.getExtension("queue-status", "http://jabber.org/protocol/workgroup"); if (pe != null) { fireQueueDepartedEvent(); } else if (queueStatus != null) { QueueUpdate queueUpdate = (QueueUpdate) queueStatus; if (queueUpdate.getPosition() != -1) { fireQueuePositionEvent(queueUpdate.getPosition()); } if (queueUpdate.getRemaingTime() != -1) { fireQueueTimeEvent(queueUpdate.getRemaingTime()); } } else { // Check if a room invitation was sent and if the sender is the // workgroup MUCUser mucUser = (MUCUser) msg.getExtension("x", "http://jabber.org/protocol/muc#user"); MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null; if (invite != null && workgroupJID.equals(invite.getFrom())) { String sessionID = null; Map metaData = null; pe = msg.getExtension(SessionID.ELEMENT_NAME, SessionID.NAMESPACE); if (pe != null) { sessionID = ((SessionID) pe).getSessionID(); } pe = msg.getExtension(MetaData.ELEMENT_NAME, MetaData.NAMESPACE); if (pe != null) { metaData = ((MetaData) pe).getMetaData(); } WorkgroupInvitation inv = new WorkgroupInvitation( connection.getUser(), msg.getFrom(), workgroupJID, sessionID, msg.getBody(), msg.getFrom(), metaData); fireInvitationEvent(inv); } } } }