linux版本中间件

Operation.h 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include "FsLinkInc.h"
  3. #include "DevInfoInc.h"
  4. #include "Util.h"
  5. #include "SqlWrite.h"
  6. class COperationReactor;
  7. class VirtualChan;
  8. class COperation
  9. {
  10. public:
  11. COperation(COperationReactor* pParent, long Instance);
  12. virtual ~COperation();
  13. virtual LINE_OP type(void) const = 0;
  14. long uniqueId(void) const { return reinterpret_cast<long>(this); }
  15. // 关联操作
  16. virtual bool attachHostChan(VirtualChan* pChan); // 设置主控通道的关联
  17. virtual void detachHostChan(void); // 取消通道关联
  18. // 控制接口
  19. virtual bool start(LineOpParam* pParam) = 0; // 操作启动(命令方式)
  20. virtual bool start(PCHAN_EVENT_NOTIFY pNotify); // 操作启动(命令方式)
  21. virtual bool cancel(long InstanceCancel); // 取消当前操作
  22. virtual bool hangup(long InstanceHangup); // 操作中挂机
  23. virtual void setOpInstance(long Instance); // 设置调用标识
  24. // 事件响应接口
  25. virtual void onBackgroudJobDone(PBG_JOB_NOTIFY pNotify); // 后台命令执行结束事件处理
  26. virtual void onAssoChanStateUpdated(VirtualChan* pAssoChan); // 相关通道状态更新处理
  27. virtual void onHostChanStateUpdated(VirtualChan* pHostChan); // 关联通道状态更新处理
  28. virtual void onSessionChanStateUpdated(VirtualChan* pChan); // 同会话中通道状态更新处理
  29. protected:
  30. COperationReactor* m_pParent; // 宿主类
  31. VirtualChan* m_pHostChan; // 当前操作的主控通道
  32. long m_Instance; // 调用标识,用于回传
  33. long m_InstanceCancel; // 启动取消操作的调用标识
  34. protected:
  35. std::string toSql(bool isSuccess,std::string opDesc) {
  36. Format fmt("insert into op_record(uuid,caller_agent,caller,callee_agent,callee,is_success,op_type,op_desc,op_time) values('%s','%s','%s','%s','%s',%d,%d,'%s','%s') ");
  37. fmt %m_SessionId %m_CallerAgent %m_Caller %m_CalleeAgent %m_Callee %isSuccess %type() % opDesc %m_OpTime;
  38. return fmt.str();
  39. }
  40. protected:
  41. std::string m_SessionId; // 会话id
  42. std::string m_CallerAgent;
  43. std::string m_Caller;
  44. std::string m_CalleeAgent;
  45. std::string m_Callee;
  46. std::string m_OpTime; //操作时间
  47. };