中间件标准版5.1git,去除基础模块

FsProxy.h 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*************************************************************************
  2. 【文件名】 FsProxy.h
  3. 【功能模块和目的】 FS代理控制类头文件
  4. 【开发者及日期】 郑石诺 2016/06/21
  5. 【版本】 V1.0.0
  6. 【版权信息】 Copyright (C)2016 河南华谊网络科技有限公司
  7. 【更改记录】
  8. *************************************************************************/
  9. #pragma once
  10. #include "EslGateway.h"
  11. #include "IEslEventHandler.h"
  12. #include "CallStringMaker.h"
  13. class CChanExten;
  14. class CChanTrunk;
  15. class CVirtualChan;
  16. class CSession;
  17. /*************************************************************************
  18. 【类名】 CFsProxy
  19. 【功能】
  20. 【接口说明】 FS代理控制类
  21. 【开发者及日期】 郑石诺 2016/06/21
  22. 【版本】 V1.0.0
  23. 【版权信息】 Copyright (C)2016 河南华谊网络科技有限公司
  24. 【更改记录】
  25. *************************************************************************/
  26. class CFsProxy
  27. {
  28. SINGLETON_DECLARE(CFsProxy)
  29. public:
  30. ~CFsProxy(void);
  31. bool init(IEslEventHandler* pEventHandler);
  32. void release(void);
  33. // 事件处理
  34. void onChanRegist(DEV_RES_TYPE ChanType, UINT ChanNo, CHAN_LOGIC_STATE ChanState);
  35. void onExtenDestroy(UINT ExtenNo);
  36. void onExtenDirectOp(DEV_OP OpType, CVirtualChan* pHostChan, PCHAN_EVENT_NOTIFY pNotify);
  37. void onChanStateUpdate(LONG OpInstance, CVirtualChan* pChan);
  38. void onChanPoor(CSession* pSession, PCHAN_EVENT_NOTIFY pNotify);
  39. void onTrunkCallIn(CChanTrunk* pTrunk);
  40. // ESL事件
  41. void onEslDisconnect(void);
  42. void onEslExtenReg(UINT ExtenNo);
  43. void onEslExtenUnreg(UINT ExtenNo);
  44. void onEslEvtBgJobDone(PBG_JOB_NOTIFY pNotify);
  45. void onEslEvtChannel(PCHAN_EVENT_NOTIFY pNotify);
  46. void onEslEvtDtmf(PDTMF_NOTIFY pNotify);
  47. void onEslEvtHold(PHOLD_NOTIFY pNotify);
  48. // 功能接口
  49. CChanExten* getExten(UINT ExtenNo);
  50. CChanTrunk* getTrunk(UINT TrunkNo);
  51. void delChan(CVirtualChan* pChan);
  52. CChanTrunk* getFreeTrunk(void);
  53. CVirtualChan* getAssoChanInSession(CVirtualChan* pChan);
  54. CVirtualChan* getBusyChan(LPCTSTR ChanId);
  55. void regBusyChan(CVirtualChan* pChan);
  56. void unregBusyChan(CVirtualChan* pChan);
  57. // 语音操作接口
  58. bool ExtenCall(LONG JobId, CVirtualChan* pChan, LPCTSTR CallerNum, LPCTSTR CalleeNum);
  59. bool PredictionCall(LONG JobId, CString CallerNum, CString CalleeNum);
  60. bool answer(LONG JobId, CVirtualChan* pChan);
  61. bool kill(LONG JobId, CVirtualChan* pChan);
  62. bool consult(LONG JobId, CVirtualChan* pChan, CString DestNum);
  63. bool insert(LONG JobId, CVirtualChan* pChan, LPCTSTR DestSessionId);
  64. bool intercept(LONG JobId, CVirtualChan* pChan, LPCTSTR DestChanId);
  65. bool listen(LONG JobId, CVirtualChan* pChan, LPCTSTR DestChanId);
  66. bool meeting(LONG JobId, CString CallerNum, CString DestNum, LPCTSTR MeetingId);
  67. std::string EslCommand(std::string strFsIp, int FsPort, std::string strName, std::string strPsWd, std::string strCommand);
  68. bool muteOn(LONG JobId, CVirtualChan* pChan);
  69. bool muteOff(LONG JobId, CVirtualChan* pChan);
  70. bool holdon(LONG JobId, CVirtualChan* pChan);
  71. bool takeBack(LONG JobId, CVirtualChan* pChan);
  72. bool record(LONG JobId, CVirtualChan* pChan, LPCTSTR RcdFile);
  73. bool transfer(LONG JobId, CVirtualChan* pChan, LPCTSTR DestNum);
  74. bool transfer2Context(LONG JobId, LPCTSTR DestChanId, LPCTSTR Exten, LPCTSTR Context, bool BothSide = false);
  75. // IVR任务
  76. bool cancel(CChanTrunk* pChan);
  77. bool hangup(CChanTrunk* pChan);
  78. bool leaveWord(CChanTrunk* pChan, LPCTSTR FileName, UINT LimitTime, TCHAR FinishKey);
  79. bool playAndDtmf(CChanTrunk* pChan, PlayVoiceContent* pPlayContent);
  80. bool bridge(CChanTrunk* pChan, CString CallerNum, CString CalleeNum);
  81. private:
  82. CFsProxy(void);
  83. UINT __transLogicState2CtiState(DEV_RES_TYPE ChanType, CHAN_LOGIC_STATE State);
  84. void __addExten(UINT ExtenNo);
  85. void __delExten(UINT ExtenNo);
  86. void __freeExten(void);
  87. void __initTrunkChan(void);
  88. void __freeTrunkChan(void);
  89. CSession* __getSession(LPCTSTR SessionId);
  90. CSession* __getSession(PCHAN_EVENT_NOTIFY pNotify, bool NewWhenNull = false);
  91. void __delSession(LPCTSTR SessionId);
  92. void __freeSession(void);
  93. bool __kill(LONG JobId, LPCTSTR ChanId);
  94. private:
  95. CEslGateway m_Gateway;
  96. CCallStringMaker m_CallStringMaker;
  97. CArray<CChanTrunk*, CChanTrunk*> m_ArrayTrunk; // 中继数组
  98. CMap<UINT, UINT, CChanExten*, CChanExten*> m_MapChanExt; // 分机表
  99. CMap<CString, LPCTSTR, CVirtualChan*, CVirtualChan*> m_MapBusyChan; // 忙通道表
  100. CMap<CString, LPCTSTR, CSession*, CSession*> m_MapSession; // 会话表
  101. IEslEventHandler* m_pEventHandler;
  102. esl_handle_t m_EslHandle;
  103. };