linux版本中间件

VirtualChan.cpp 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "VirtualChan.h"
  2. #include "Log.h"
  3. #include "FsProxy.h"
  4. #include "Operation.h"
  5. #include "OperationReactor.h"
  6. VirtualChan::VirtualChan(CFsProxy* pParent, uint32_t ChanNo) : m_pParent(pParent), m_No(ChanNo), m_State(CHAN_LOGIC_STATE_FREE), m_IsInMeeting(false), m_pOperation(nullptr), m_RecordFile("")
  7. {
  8. }
  9. VirtualChan::~VirtualChan()
  10. {
  11. }
  12. void VirtualChan::setRecordFile(const std::string & strFileName)
  13. {
  14. if (strFileName != "" && m_RecordFile == "")
  15. {
  16. m_RecordFile = strFileName;
  17. std::string data = m_pParent->creatJsonRecord(m_SessionId, m_RecordFile);
  18. m_pParent->send2Agent(std::to_string(m_No), data);
  19. }
  20. }
  21. void VirtualChan::_setSession(string SessionId, string ChanId)
  22. {
  23. m_SessionId = SessionId;
  24. if (!ChanId.empty())
  25. {
  26. m_ChanId = ChanId;
  27. m_pParent->regBusyChan(this);
  28. }
  29. else
  30. {
  31. m_pParent->unregBusyChan(this);
  32. m_ChanId.clear();
  33. }
  34. }
  35. void VirtualChan::_reset(void)
  36. {
  37. LOG_INFO("{CVirtualChan}: 执行线路[%lu]重置", m_No);
  38. m_State = CHAN_LOGIC_STATE_FREE;
  39. m_IsInMeeting = false;
  40. m_CalleeNum.clear();
  41. m_CalleeNum.clear();
  42. m_ChanId.clear();
  43. m_SessionId.clear();
  44. m_OpNumber.clear();
  45. m_RecordFile = "";
  46. }
  47. bool VirtualChan::bindOp(COperation * pOp)
  48. {
  49. if(pOp==nullptr || m_pOperation !=nullptr)
  50. return false;
  51. m_pOperation = pOp;
  52. return true;
  53. }
  54. bool VirtualChan::releaseOp(COperation * pOp)
  55. {
  56. if(m_pOperation != pOp)
  57. return false;
  58. m_pOperation = nullptr;
  59. return true;
  60. }