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

OpMute.cpp 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. return CFsProxy::GetInstance().muteOff(uniqueId(), m_pHostChan);
  67. }
  68. /*****************************************************************
  69. **【函数名称】 hangup
  70. **【函数功能】 操作中挂机
  71. **【参数】
  72. **【返回值】
  73. *****************************************************************/
  74. bool COpMute::hangup( LONG InstanceHangup )
  75. {
  76. if(m_InstanceCancel != FS_LINK_INSTANCE_INVALID)
  77. return false;
  78. LOGGER(LOG_LEVEL_NORMAL, _T("{OpMute}: 分机[%lu]静音中挂机"), m_pHostChan->no());
  79. m_InstanceCancel = InstanceHangup;
  80. if(CFsProxy::GetInstance().kill(uniqueId(), m_pHostChan))
  81. {
  82. _end(false);
  83. return true;
  84. }
  85. else
  86. {
  87. _end(true);
  88. return false;
  89. }
  90. }
  91. /*****************************************************************
  92. **【函数名称】 onBackgroudJobDone
  93. **【函数功能】 后台命令执行结束事件处理
  94. **【参数】
  95. **【返回值】
  96. *****************************************************************/
  97. void COpMute::onBackgroudJobDone( PBG_JOB_NOTIFY pNotify )
  98. {
  99. if(m_IsOff)
  100. {
  101. if(strstr(pNotify->JobBody, ESL_JOB_DONE_RES_OK) == NULL)
  102. m_pParent->onOpResult(m_InstanceCancel, false); // 取消静音不成功不删该操作,以备再次取消静音之用
  103. else
  104. _end(true);
  105. }
  106. else
  107. {
  108. if(strstr(pNotify->JobBody, ESL_JOB_DONE_RES_OK) == NULL)
  109. _end(false);
  110. else
  111. m_pParent->onOpResult(m_Instance, true); // 静音成功不删该操作,以备取消静音之用
  112. }
  113. }
  114. /*****************************************************************
  115. **【函数名称】 onHostChanStateUpdated
  116. **【函数功能】 关联通道状态更新处理
  117. **【参数】
  118. **【返回值】
  119. *****************************************************************/
  120. void COpMute::onHostChanStateUpdated( CVirtualChan* pHostChan )
  121. {
  122. if(m_pHostChan->state() == CHAN_LOGIC_STATE_FREE)
  123. _end(false);
  124. }