linux版本中间件

EslGateway.h 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "Log.h"
  3. #include <esl.h>
  4. #include "FsLinkInc.h"
  5. #include <iostream>
  6. typedef struct
  7. {
  8. std::string name; // 座席名字
  9. std::string system;
  10. std::string uuid;
  11. std::string type; //
  12. std::string contact; // 呼叫字符串
  13. std::string status; // 座席状态 忙,闲 Logged Out Available On Break
  14. std::string state; // Idle Waiting Receiving In a queue call
  15. void to_string() {
  16. Format fmt("name = %s,system = %s,uuid = %s,type = %s,contact = %s,status = %s,state = %s");
  17. fmt %name %system %uuid %type %contact %status %state;
  18. LOG_INFO_S(fmt.str());
  19. std::cout << fmt.str() << std::endl;
  20. }
  21. }AgentDetail;
  22. class CFsProxy;
  23. class CEslGateway
  24. {
  25. public:
  26. CEslGateway(CFsProxy* pParent);
  27. ~CEslGateway();
  28. // 控制接口
  29. bool start(void);
  30. void stop(void);
  31. bool hangupAll(void);
  32. bool scanExten(void);
  33. bool getAgentState(std::string AgentID, AgentDetail &agent);
  34. bool delAgentAll(void);
  35. bool delAgent(std::string AgentID);
  36. bool delAgent(std::string AgentID,std::list<std::string> Groups);
  37. bool sendCmd(string pCmd);
  38. bool execute(esl_handle_t* pHandle, const char* App, const char* Param);
  39. bool Execte(const char* App, const char* Param, const char* ChanId);
  40. private:
  41. // 事件处理的线程函数
  42. void __eventThread(void);
  43. void __onEslEvent(esl_event_t* pEvent);
  44. void __onEslDisconnect(void);
  45. void __onEslEvtBgJobDone(esl_event_t* pEvent);
  46. void __onEslEvtChanEvent(esl_event_t* pEvent);
  47. void __onEslEvtCustom(esl_event_t* pEvent);
  48. void __onEslEvtDtmf(esl_event_t* pEvent);
  49. void __onEslEvtHold(esl_event_t* pEvent, EVENT_HOLD_TYPE EvtType);
  50. private:
  51. CFsProxy* m_pParent;
  52. volatile bool m_Stop;
  53. esl_handle_t m_EslHdl4Listen; // 监听FreeSWITCH消息
  54. esl_handle_t m_EslHdl4Send; // 向FreeSWITCH发送命令
  55. };