当前位置: 首页>>代码示例>>Java>>正文


Java AgentStatus类代码示例

本文整理汇总了Java中org.jivesoftware.smackx.workgroup.packet.AgentStatus的典型用法代码示例。如果您正苦于以下问题:Java AgentStatus类的具体用法?Java AgentStatus怎么用?Java AgentStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AgentStatus类属于org.jivesoftware.smackx.workgroup.packet包,在下文中一共展示了AgentStatus类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateNumberOfChats

import org.jivesoftware.smackx.workgroup.packet.AgentStatus; //导入依赖的package包/类
private void calculateNumberOfChats(AgentRoster agentRoster) {
    int counter = 0;
    // TODO: CHECK FASTPATH
    //for (String agent : agentRoster.getAgents()) {
    for (Iterator it = agentRoster.getAgents().iterator(); it.hasNext();) {
        String agent = (String)it.next();        	
        Presence presence = agentRoster.getPresence(agent);
        if (presence.isAvailable()) {
            AgentStatus agentStatus = (AgentStatus)presence.getExtension("agent-status", "http://jabber.org/protocol/workgroup");
            if (agentStatus != null) {
                counter += agentStatus.getCurrentChats().size();
            }
        }
    }

    FastpathPlugin.getUI().setTitleForComponent(FpRes.getString("message.current.chats", counter), this);
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:18,代码来源:AgentConversations.java

示例2: setStatus

import org.jivesoftware.smackx.workgroup.packet.AgentStatus; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:57,代码来源:AgentSession.java

示例3: newListHasSession

import org.jivesoftware.smackx.workgroup.packet.AgentStatus; //导入依赖的package包/类
private boolean newListHasSession(String sessionID, List chatList) {
    // Add new ones.
    Iterator iter = chatList.iterator();
    while (iter.hasNext()) {
        AgentStatus.ChatInfo chatInfo = (AgentStatus.ChatInfo)iter.next();
        String session = chatInfo.getSessionID();
        if (session.equalsIgnoreCase(sessionID)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:13,代码来源:AgentConversations.java

示例4: buildTooltip

import org.jivesoftware.smackx.workgroup.packet.AgentStatus; //导入依赖的package包/类
private String buildTooltip(Presence presence) {
    if (!presence.isAvailable()) {
        return FpRes.getString("message.user.not.logged.in");
    }

    AgentStatus agentStatus = (AgentStatus)presence.getExtension("agent-status", "http://jabber.org/protocol/workgroup");
    List<AgentStatus.ChatInfo> list = agentStatus.getCurrentChats();

    // Add new ones.
    Iterator<AgentStatus.ChatInfo> iter = list.iterator();
    StringBuffer buf = new StringBuffer();
    buf.append("<html>");
    buf.append("<body>");
    buf.append("<table>");

    while (iter.hasNext()) {
        AgentStatus.ChatInfo chatInfo = iter.next();
        Date startDate = chatInfo.getDate();
        String username = chatInfo.getUserID();

        String nickname = chatInfo.getUsername();
        if (!ModelUtil.hasLength(nickname)) {
            nickname = FpRes.getString("message.not.specified");
        }

        String question = chatInfo.getQuestion();
        if (!ModelUtil.hasLength(question)) {
            question = "No question asked";
        }

        String email = chatInfo.getEmail();
        if (!ModelUtil.hasLength(email)) {
            email = FpRes.getString("message.not.specified");
        }

        long startTime = startDate.getTime();
        long rightNow = System.currentTimeMillis();
        long totalTime = rightNow - startTime;
        String durationTime = ModelUtil.getTimeFromLong(totalTime);

        buf.append("<tr><td><b><u>Chatting with ").append(nickname).append("</u></b></td></tr>");
        buf.append("<tr><td>Email: ").append(email).append("</td></tr>");
        buf.append("<tr><td>Question: ").append(question).append("</td></tr>");
        buf.append("<tr><td>Chat Duration: ").append(durationTime).append("</td></tr>");
        buf.append("<tr><td><br></td></tr>");
    }

    if (list.size() == 0) {
        buf.append(FpRes.getString("message.agent.is.not.in.chat"));
    }

    buf.append("</table>");
    buf.append("</body>");
    buf.append("</html>");
    return buf.toString();
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:57,代码来源:OnlineAgents.java


注:本文中的org.jivesoftware.smackx.workgroup.packet.AgentStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。