#pragma once #include #include "WebSocketServer.h" #include #include "Log.h" #include "ITimer.h" #include "TimeScheduler.h" #include using namespace boost::posix_time; //类型定义:座席当前的状态 typedef enum tagAGENT_STATE { AGENT_STATE_UNKNOWN = 0x00, // 未知 // 座席逻辑状态 AGENT_STATE_LOGING = 0x01, // 登录中 AGENT_STATE_FREE = 0x02, // 空闲 AGENT_STATE_BUSY = 0x03, // 通话中 AGENT_STATE_POST_PROCESSING = 0x04, // 话后处理 AGENT_STATE_REPOSE = 0x05, // 小休 AGENT_STATE_REQUESTED = 0x06, // 被请求 AGENT_STATE_LOGOUT = 0x07 // 注销 } AGENT_STATE; class Agent { public: Agent(std::string a_AgentID,std::string a_ExtID); Agent(std::string a_AgentID, std::string a_ExtID,std::string a_Group); virtual ~Agent(); void removeAgent(std::string HostAgent); // 签出 bool setState(AGENT_STATE a_AgentState); std::string assoExten(void) const { return m_Exten; } // 读取关联的分机ID std::string id(void) const { return m_AgentID; } // 读取座席工号 bool isRepose(void) const { return m_IsRepose; } // 读取座席是否置忙 AGENT_STATE state() const { return m_State; } // 坐席状态 std::string state_s() ; websocketpp::connection_hdl hdl() const { return m_hdl; } websocketpp::connection_hdl& hdl() { return m_hdl; } std::list groups() const { return m_Groups; }; std::string group() const { return m_Group; }; /*视频相关,请求空闲坐席*/ bool VideoLock() { if (m_State == AGENT_STATE_FREE && !m_bVideoLock) { m_bVideoLock = true; return true; } return false; } /*取消视频请求锁定*/ bool CancelVideoLock() { m_bVideoLock = false; return true; } private: bool __login(); bool __logout(); bool __statistics(AGENT_STATE a_AgentState); // 坐席状态统计 std::string __FormatTime(ptime time); // 2023-06-02 15:59:00 std::string __FormatTimeV2(ptime time); // 20230602155900 ptime __getCurTime(); int64_t __subTime(ptime before, ptime after); protected: //virtual void onTimer(); // 定时器函数 private: std::string m_AgentID; std::string m_Exten; bool m_IsRepose; // 是否小休 AGENT_STATE m_State; ptime m_TimeLogin; ptime m_TimeLogout; ptime ptStartTalk; // 通话开始时间 ptime ptStartFree; // 空闲开始时间 ptime ptStartRepose;// 小休开始时间 ptime ptStartRing;// 振铃开始时间,呼入/呼出振铃 std::string loginID ; // uint64_t m_LoginTimes; // 签入时长 uint64_t m_FreeTimes; // 空闲时长 uint64_t m_ReposeTimes; // 小休时长 uint64_t m_TalkTimes; // 通话时长 uint32_t m_ReposeNum; // 小休次数 uint32_t m_AnswerNum; // 应答次数 uint32_t m_LogoutType; // 签出类型 std::list m_Groups; // 坐席组,分割后 std::string m_Group; // 坐席组,未分割 websocketpp::connection_hdl m_hdl; /*视频相关*/ bool m_bVideoLock; // 是否锁定 };