中间件底层,websocket

OpMute.cpp 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #include "StdAfx.h"
  2. #include "OpMute.h"
  3. #include "VirtualChan.h"
  4. #include "OperationReactor.h"
  5. #include "FsProxy.h"
  6. COpMute::COpMute(COperationReactor* pParent, LONG Instance) : COperation(pParent, Instance), m_IsOff(false)
  7. {
  8. }
  9. COpMute::~COpMute(void)
  10. {
  11. }
  12. /*****************************************************************
  13. **【函数名称】 _end
  14. **【函数功能】 操作完成
  15. **【参数】 IsSucceed 操作是否成功
  16. lpData 随路数据
  17. **【返回值】
  18. ****************************************************************/
  19. void COpMute::_end( bool IsSucceed )
  20. {
  21. if(m_IsOff)
  22. {
  23. if(IsSucceed)
  24. LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]取消静音成功"), m_pHostChan->no());
  25. else
  26. LOGGER(LOG_LEVEL_WARNING, _T("{OpMute}: 分机[%lu]取消静音失败"), m_pHostChan->no());
  27. m_pParent->onOpResult(m_InstanceCancel, IsSucceed);
  28. }
  29. else
  30. {
  31. if(IsSucceed)
  32. LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]静音成功"), m_pHostChan->no());
  33. else
  34. LOGGER(LOG_LEVEL_WARNING, _T("{OpMute}: 分机[%lu]静音失败"), m_pHostChan->no());
  35. // 返回执行结果
  36. if(m_InstanceCancel != FS_LINK_INSTANCE_INVALID)
  37. m_pParent->onOpResult(m_InstanceCancel, !IsSucceed);
  38. m_pParent->onOpResult(m_Instance, this, IsSucceed);
  39. }
  40. }
  41. /*****************************************************************
  42. **【函数名称】 start
  43. **【函数功能】 执行操作
  44. **【参数】
  45. **【返回值】
  46. *****************************************************************/
  47. bool COpMute::start( LineOpParam* pParam )
  48. {
  49. // 校验状态
  50. if(m_pHostChan->state() != CHAN_LOGIC_STATE_TALKING)
  51. return false;
  52. LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]执行静音"), m_pHostChan->no());
  53. return CFsProxy::GetInstance().muteOn(uniqueId(), m_pHostChan);
  54. }
  55. /*****************************************************************
  56. **【函数名称】 cancel
  57. **【函数功能】 取消操作
  58. **【参数】
  59. **【返回值】
  60. *****************************************************************/
  61. bool COpMute::cancel( LONG InstanceCancel )
  62. {
  63. LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]取消静音"), m_pHostChan->no());
  64. m_InstanceCancel = InstanceCancel;
  65. m_IsOff = true;
  66. bool b = CFsProxy::GetInstance().muteOff(uniqueId(), m_pHostChan);
  67. m_pHostChan->releaseOp(m_pHostChan->currOp()); //TJ 静音接回后,释放当前操作。否则无法挂机 2021.11.25
  68. return b;
  69. }
  70. /*****************************************************************
  71. **【函数名称】 hangup
  72. **【函数功能】 操作中挂机
  73. **【参数】
  74. **【返回值】
  75. *****************************************************************/
  76. bool COpMute::hangup( LONG InstanceHangup )
  77. {
  78. if(m_InstanceCancel != FS_LINK_INSTANCE_INVALID)
  79. return false;
  80. LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]静音中挂机"), m_pHostChan->no());
  81. m_InstanceCancel = InstanceHangup;
  82. if(CFsProxy::GetInstance().kill(uniqueId(), m_pHostChan))
  83. {
  84. _end(false);
  85. return true;
  86. }
  87. else
  88. {
  89. _end(true);
  90. return false;
  91. }
  92. }
  93. /*****************************************************************
  94. **【函数名称】 onBackgroudJobDone
  95. **【函数功能】 后台命令执行结束事件处理
  96. **【参数】
  97. **【返回值】
  98. *****************************************************************/
  99. void COpMute::onBackgroudJobDone( PBG_JOB_NOTIFY pNotify )
  100. {
  101. if(m_IsOff)
  102. {
  103. if(strstr(pNotify->JobBody, ESL_JOB_DONE_RES_OK) == NULL)
  104. m_pParent->onOpResult(m_InstanceCancel, false); // 取消静音不成功不删该操作,以备再次取消静音之用
  105. else
  106. _end(true);
  107. }
  108. else
  109. {
  110. if(strstr(pNotify->JobBody, ESL_JOB_DONE_RES_OK) == NULL)
  111. _end(false);
  112. else
  113. m_pParent->onOpResult(m_Instance, true); // 静音成功不删该操作,以备取消静音之用
  114. }
  115. }
  116. /*****************************************************************
  117. **【函数名称】 onHostChanStateUpdated
  118. **【函数功能】 关联通道状态更新处理
  119. **【参数】
  120. **【返回值】
  121. *****************************************************************/
  122. void COpMute::onHostChanStateUpdated( CVirtualChan* pHostChan )
  123. {
  124. if(m_pHostChan->state() == CHAN_LOGIC_STATE_FREE)
  125. _end(false);
  126. }