linux版本中间件

Session.h 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. int getActionId()const { return m_AtionId; }
  21. // 判断通道id是否属于当前会话
  22. bool isContainChanId(const std::string& chanId);
  23. // 操作接口
  24. void prepare(PCHAN_EVENT_NOTIFY pNotify);
  25. void onChanEvent(PCHAN_EVENT_NOTIFY pNotify);
  26. void onChanDtmf(PDTMF_NOTIFY pNotify);
  27. void onChanHold(PHOLD_NOTIFY pNotify);
  28. VirtualChan* getAssoChan(VirtualChan* pChan);
  29. VirtualChan* getAssoFinalChan(); // 最后一条通道
  30. VirtualChan* getAssoFinalChan(VirtualChan* pChan); // 最后一条通道
  31. private:
  32. VirtualChan* __getFirstChan();
  33. VirtualChan* __getChan(string ChanId);
  34. VirtualChan* __findChan(PCHAN_EVENT_NOTIFY pNotify);
  35. void __addChan(VirtualChan* pChan);
  36. void __delChan(VirtualChan* pChan);
  37. void __clearChan(void);
  38. void __notifySessionChanEvent(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify);
  39. void __notifyIncomingChanEvent(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify);
  40. void __notifyDbSaveChanEvent(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify); // 判断保存通话记录到数据库
  41. void __saveAutoCallDB(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify); // 保存自动外呼通话记录
  42. void __onChanFree(VirtualChan* pChan, PCHAN_EVENT_NOTIFY pNotify);
  43. void __onPlayAgentNo(VirtualChan* pChan, PCHAN_EVENT_NOTIFY pNotify);
  44. void __onRecord(VirtualChan* pChan, PCHAN_EVENT_NOTIFY pNotify);
  45. void __createFileName(VirtualChan* pChan);
  46. void __onLineTalking(VirtualChan* pChan);
  47. private:
  48. CFsProxy* m_pParent;
  49. string m_Id;
  50. list<VirtualChan*> m_ListChan;
  51. std::mutex m_ChanLock;
  52. std::string m_RingTime; // 被叫振铃时间
  53. std::string m_AnswerTime; // 被叫应答时间
  54. bool m_IsAnswer; // 是否接听
  55. volatile bool m_IsSaveDb; // 是否更新数据库,一通电话会产生两次挂机事件,依据第一次收到的挂机事件保存,第二次收到后不保存
  56. volatile int m_AtionId;// 默认0,成功接听一通后+1
  57. std::string m_RecordFile; // 录音路径
  58. };