fastpath在前一章有做了一些介绍,是openfire提供的一种可以实现客服功能的插件。
这里把自己查看源码看到一些主要几个类来说明一下这个fastpath的主要对象。
1.agent
这是对于的客服的实体对象,主要就是记录一些基本的属性,比如:agent的昵称,jid等
public class Agent {
private static final Logger Log = LoggerFactory.getLogger(Agent.class);
private static final String LOAD_AGENT =
"SELECT name, agentJID, maxchats FROM fpAgent WHERE agentID=?";
private static final String SAVE_AGENT =
"UPDATE fpAgent SET name=?, agentJID=?, maxchats=? WHERE agentID=?";
/**
* The agent session created when the agent joined the service.
*/
private AgentSession session;
/**
* The ceiling on the maximumn number of chats the agent should handle.
*/
protected int maxChats = 0;
/**
* Nickname of the agent.
*/
private String nickname;
/**
* Custom properties for the agent.
*/
private JiveLiveProperties properties;
/**
* The id of the agent.
*/
private long id;
/**
* The XMPP address of the Agent.
*/
private JID agentJID;
2.agentManager
这个类很好理解就是对agent这个实体类的管理类,openfire中的一些实体对象一样整个代码主要是用一些sql语句实现了基本的增删改查。
public class AgentManager {
private static final Logger Log = LoggerFactory.getLogger(AgentManager.class);
private static final String LOAD_AGENTS =
"SELECT agentID FROM fpAgent";
private static final String INSERT_AGENT =
"INSERT INTO fpAgent (agentID, agentJID, name, maxchats, minchats) VALUES (?,?,?,?,?)";
private static final String DELETE_AGENT =
"DELETE FROM fpAgent WHERE agentID=?";
private static final String DELETE_AGENT_PROPS =
"DELETE FROM fpAgentProp WHERE ownerID=?";
3.agentSession
这个对象顾名思义agent的会话实体。从类的属性可以看出,这个实体是对应一个agent对象,包含了这个agent在各个技能组的聊天会话的集合,加入的技能组集合,以及这个agent的最大的聊天室,出席包的状态等都在这个类中定义。这个是在后面操作中比较常用的类。以及一些事件的监听类
public class AgentSession {
private static final Logger Log = LoggerFactory.getLogger(AgentSession.class);
private static final FastDateFormat UTC_FORMAT = FastDateFormat.getInstance("yyyyMMdd'T'HH:mm:ss", TimeZone.getTimeZone("GMT+0"));
private Presence presence;
private Collection<Workgroup> workgroups = new ConcurrentLinkedQueue<Workgroup>();
private Offer offer;
/**
* Flag that indicates if the agent requested to get information of agents of all the workgroups
* where the agent has joined.
*/
private boolean requestedAgentInfo = false;
private Map<Workgroup, Queue<ChatInfo>> chatInfos = new ConcurrentHashMap<Workgroup, Queue<ChatInfo>>();
/**
* By default maxChats has a value of -1 which means that #getMaxChats will return
* the max number of chats per agent defined in the workgroup. The agent may overwrite
* the default value but the new value will not be persisted for future sessions.
*/
private