protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String workgroupName = request.getParameter("workgroup"); String action = request.getParameter("action"); Workgroup workgroup = new Workgroup(workgroupName, ChatManager.getInstance().getGlobalConnection()); try { SoundSettings soundSettings = workgroup.getSoundSettings(); response.setContentType("audio/wav"); if (action != null) { if ("incoming".equals(action.trim())) { response.getOutputStream().write(soundSettings.getIncomingSoundBytes()); } else if ("outgoing".equals(action.trim())) { response.getOutputStream().write(soundSettings.getOutgoingSoundBytes()); } } } catch (XMPPException e) { WebLog.log("Could not load sound settings for workgroup " + workgroupName); } }
/** * Joins a queue of the specified workgroup with the associated metadata. * * @param workgroupName the name of the workgroup to join. * @param metaData the metadata associated with this request. * @throws XMPPException if an error occurs. */ public void joinQueue(String workgroupName, Map metaData) throws XMPPException { // Never have null values in metadata if (metaData.containsValue(null)) { WebLog.logError("You cannot have null values in the Metadata."); return; } workgroup = new Workgroup(workgroupName, connection); workgroup.addInvitationListener(new WorkgroupInvitationListener() { public void invitationReceived(WorkgroupInvitation workgroupInvitation) { String room = workgroupInvitation.getGroupChatName(); joinRoom(room); } }); if (workgroup != null) { try { workgroup.joinQueue(metaData, userid); } catch (XMPPException e) { WebLog.logError("Unable to join chat queue.", e); } } // If metadata about the users name is present, use it to set the name. if (metaData.containsKey("username")) { name = (String)metaData.get("username"); } if (name == null) { name = "Visitor"; } metadataMap = metaData; }
public static ChatQueue getChatQueue(String chatID) { ChatSession chatSession = getChatSession(chatID); if (chatSession == null) { return null; } ChatQueue queue = new ChatQueue(); if (chatSession.isClosed()) { queue.setConnectionDropped(true); return queue; } // We've been routed to an agent and received a MUC Invite. if (chatSession.isInGroupChat()) { queue.setRouted(true); queue.setInQueue(false); return queue; } else if (chatSession.isInQueue()) { final Workgroup workgroup = chatSession.getWorkgroup(); if (workgroup != null) { queue.setQueuePosition(workgroup.getQueuePosition()); queue.setQueueTime(workgroup.getQueueRemainingTime()); queue.setInQueue(true); } return queue; } else if (!chatSession.isInQueue() && !chatSession.isInGroupChat()) { try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } queue.setConnectionDropped(!chatSession.isInQueue() && !chatSession.isInGroupChat()); return queue; } if (!chatSession.getWorkgroup().isAvailable()) { queue.setConnectionDropped(true); chatSession.close(); } return queue; }
public static Workgroup getWorkgroup() { return wgroup; }
/** * Returns the workgroup associated with this <code>ChatSession</code>. * * @return the workgroup associated with this ChatSession. */ public Workgroup getWorkgroup() { return workgroup; }