linux版本中间件

Agent.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. /*视频相关,请求空闲坐席*/
  41. bool VideoLock() {
  42. if (m_State == AGENT_STATE_FREE && !m_bVideoLock) {
  43. m_bVideoLock = true;
  44. return true;
  45. }
  46. return false;
  47. }
  48. /*取消视频请求锁定*/
  49. bool CancelVideoLock() {
  50. m_bVideoLock = false;
  51. return true;
  52. }
  53. private:
  54. bool __login();
  55. bool __logout();
  56. bool __statistics(AGENT_STATE a_AgentState); // 坐席状态统计
  57. std::string __FormatTime(ptime time); // 2023-06-02 15:59:00
  58. std::string __FormatTimeV2(ptime time); // 20230602155900
  59. ptime __getCurTime();
  60. int64_t __subTime(ptime before, ptime after);
  61. protected:
  62. //virtual void onTimer(); // 定时器函数
  63. private:
  64. std::string m_AgentID;
  65. std::string m_Exten;
  66. bool m_IsRepose; // 是否小休
  67. AGENT_STATE m_State;
  68. ptime m_TimeLogin;
  69. ptime m_TimeLogout;
  70. ptime ptStartTalk; // 通话开始时间
  71. ptime ptStartFree; // 空闲开始时间
  72. ptime ptStartRepose;// 小休开始时间
  73. ptime ptStartRing;// 振铃开始时间,呼入/呼出振铃
  74. std::string loginID ; //
  75. uint64_t m_LoginTimes; // 签入时长
  76. uint64_t m_FreeTimes; // 空闲时长
  77. uint64_t m_ReposeTimes; // 小休时长
  78. uint64_t m_TalkTimes; // 通话时长
  79. uint32_t m_ReposeNum; // 小休次数
  80. uint32_t m_AnswerNum; // 应答次数
  81. uint32_t m_LogoutType; // 签出类型
  82. std::list<std::string> m_Groups; // 坐席组,分割后
  83. std::string m_Group; // 坐席组,未分割
  84. websocketpp::connection_hdl m_hdl;
  85. /*视频相关*/
  86. bool m_bVideoLock; // 是否锁定
  87. };