linux版本中间件

Agent.h 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <iostream>
  3. #include "WebSocketServer.h"
  4. #include <boost/date_time/posix_time/posix_time.hpp>
  5. #include "Log.h"
  6. #include "ITimer.h"
  7. #include "TimeScheduler.h"
  8. #include <list>
  9. using namespace boost::posix_time;
  10. //类型定义:座席当前的状态
  11. typedef enum tagAGENT_STATE
  12. {
  13. AGENT_STATE_UNKNOWN = 0x00, // 未知
  14. // 座席逻辑状态
  15. AGENT_STATE_LOGING = 0x01, // 登录中
  16. AGENT_STATE_FREE = 0x02, // 空闲
  17. AGENT_STATE_BUSY = 0x03, // 通话中
  18. AGENT_STATE_POST_PROCESSING = 0x04, // 话后处理
  19. AGENT_STATE_REPOSE = 0x05, // 小休
  20. AGENT_STATE_REQUESTED = 0x06, // 被请求
  21. AGENT_STATE_LOGOUT = 0x07 // 注销
  22. } AGENT_STATE;
  23. class Agent
  24. {
  25. public:
  26. Agent(std::string a_AgentID,std::string a_ExtID);
  27. Agent(std::string a_AgentID, std::string a_ExtID,std::string a_Group);
  28. virtual ~Agent();
  29. void removeAgent(std::string HostAgent); // 签出
  30. bool setState(AGENT_STATE a_AgentState);
  31. std::string assoExten(void) const { return m_Exten; } // 读取关联的分机ID
  32. std::string id(void) const { return m_AgentID; } // 读取座席工号
  33. bool isRepose(void) const { return m_IsRepose; } // 读取座席是否置忙
  34. AGENT_STATE state() const { return m_State; } // 坐席状态
  35. std::string state_s() ;
  36. websocketpp::connection_hdl hdl() const { return m_hdl; }
  37. websocketpp::connection_hdl& hdl() { return m_hdl; }
  38. std::list<std::string> groups() const { return m_Groups; };
  39. std::string group() const { return m_Group; };
  40. private:
  41. bool __login();
  42. bool __logout();
  43. std::string __FormatTime(ptime time);
  44. ptime __getCurTime();
  45. int64_t __subTime(ptime before, ptime after);
  46. protected:
  47. //virtual void onTimer(); // 定时器函数
  48. private:
  49. std::string m_AgentID;
  50. std::string m_Exten;
  51. bool m_IsRepose; // 是否小休
  52. AGENT_STATE m_State;
  53. ptime m_TimeLogin;
  54. ptime m_TimeLogout;
  55. uint64_t m_LoginTimes; // 签入时长
  56. uint32_t m_FreeTimes; // 空闲时长
  57. uint32_t m_ReposeTimes; // 小休时长
  58. uint32_t m_TalkTimes; // 通话时长
  59. uint32_t m_ReposeNum; // 小休次数
  60. uint32_t m_AnswerNum; // 应答次数
  61. uint32_t m_LogoutType; // 签出类型
  62. std::list<std::string> m_Groups; // 坐席组,分割后
  63. std::string m_Group; // 坐席组,未分割
  64. websocketpp::connection_hdl m_hdl;
  65. };