linux版本中间件

Session.h 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #include <iostream>
  3. #include <list>
  4. #include "FsLinkInc.h"
  5. #include "OperationReactor.h"
  6. using namespace std;
  7. class CFsProxy;
  8. class VirtualChan;
  9. class Session
  10. {
  11. public:
  12. Session(CFsProxy* pParent, string Id);
  13. ~Session();
  14. // 属性接口
  15. string id(void) const { return m_Id; }
  16. bool isVoid(void) const { return m_ListChan.empty(); }
  17. std::string& recordFile() { return m_RecordFile; }
  18. std::string& ringTime() { return m_RingTime; }
  19. std::string& answerTime() { return m_AnswerTime; }
  20. // 操作接口
  21. void prepare(PCHAN_EVENT_NOTIFY pNotify);
  22. void onChanEvent(PCHAN_EVENT_NOTIFY pNotify);
  23. void onChanDtmf(PDTMF_NOTIFY pNotify);
  24. void onChanHold(PHOLD_NOTIFY pNotify);
  25. VirtualChan* getAssoChan(VirtualChan* pChan);
  26. private:
  27. VirtualChan* __getFirstChan();
  28. VirtualChan* __getChan(string ChanId);
  29. VirtualChan* __findChan(PCHAN_EVENT_NOTIFY pNotify);
  30. void __addChan(VirtualChan* pChan);
  31. void __delChan(VirtualChan* pChan);
  32. void __clearChan(void);
  33. void __notifySessionChanEvent(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify);
  34. void __notifyIncomingChanEvent(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify);
  35. void __notifyDbSaveChanEvent(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify); // 判断保存通话记录到数据库
  36. void __saveAutoCallDB(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify); // 保存自动外呼通话记录
  37. void __onChanFree(VirtualChan* pChan, PCHAN_EVENT_NOTIFY pNotify);
  38. void __onPlayAgentNo(VirtualChan* pChan, PCHAN_EVENT_NOTIFY pNotify);
  39. void __onRecord(VirtualChan* pChan, PCHAN_EVENT_NOTIFY pNotify);
  40. private:
  41. CFsProxy* m_pParent;
  42. string m_Id;
  43. list<VirtualChan*> m_ListChan;
  44. //std::mutex m_ChanLock;
  45. std::string m_RingTime; // 被叫振铃时间
  46. std::string m_AnswerTime; // 被叫应答时间
  47. bool m_IsAnswer; // 是否接听
  48. volatile bool m_IsSaveDb; // 是否更新数据库,一通电话会产生两次挂机事件,依据第一次收到的挂机事件保存,第二次收到后不保存
  49. volatile int m_AtionId;// 默认1,成功接听一通后+1
  50. std::string m_RecordFile; // 录音路径
  51. };