InitiativeTransfer_client_g.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef __INITIATIVETRANSFER_CLIENT_G_H
  2. #define __INITIATIVETRANSFER_CLIENT_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "InitiativeTransfer_def_g.h"
  6. namespace InitiativeTransfer {
  7. class FlowService_ClientBase : public CClientSessionBase {
  8. public:
  9. explicit FlowService_ClientBase(CEntityBase *pEntity) : m_pEntityBase(pEntity), m_bSysManaged(false) {}
  10. FlowService_ClientBase* operator () (const linkContext &curLink)
  11. {
  12. m_context = curLink;
  13. return this;
  14. }
  15. protected:
  16. virtual ~FlowService_ClientBase()
  17. {
  18. /// override by user
  19. }
  20. public:
  21. void OnConnectSucceed()
  22. {
  23. bSessionClosed = false;
  24. }
  25. void OnClose(ErrorCodeEnum)
  26. {
  27. bSessionClosed = true;
  28. }
  29. bool QuerySessionClosed()
  30. {
  31. return bSessionClosed;
  32. }
  33. ErrorCodeEnum Connect(CSmartPointer<IAsynWaitSp> &spAsyncWait)
  34. {
  35. CSmartPointer<IEntityFunction> pFunc = m_pEntityBase->GetFunction();
  36. ErrorCodeEnum Error = pFunc->ConnectRemoteEntity(this, "InitiativeTransfer", "FlowService", spAsyncWait);
  37. if (Error == Error_Succeed) {
  38. m_bSysManaged = true;
  39. bSessionClosed = false;
  40. }
  41. return Error;
  42. }
  43. ErrorCodeEnum Connect()
  44. {
  45. CSmartPointer<IAsynWaitSp> spAsyncWait;
  46. ErrorCodeEnum Error = Connect(spAsyncWait);
  47. if (Error == Error_Succeed) {
  48. Error = spAsyncWait->WaitAnswer();
  49. }
  50. return Error;
  51. }
  52. ErrorCodeEnum SwitchToAgentFlow(FlowService_SwitchToAgentFlow_Info &Info)
  53. {
  54. CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
  55. if (m_context.checkEmpty())
  56. {
  57. m_context.AutoGenerate();
  58. DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
  59. m_context = m_context.upgradeLink();
  60. }
  61. CAutoBuffer Buf = SpObject2Buffer(Info);
  62. auto ret = pFunc->OnewayCall(FlowService_Method_SwitchToAgentFlow, FlowService_MethodSignature_SwitchToAgentFlow, Buf, m_context);
  63. m_context.clear();
  64. return ret;
  65. }
  66. ErrorCodeEnum DisallowControl(FlowService_DisallowControl_Info &Info)
  67. {
  68. CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
  69. if (m_context.checkEmpty())
  70. {
  71. m_context.AutoGenerate();
  72. DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
  73. m_context = m_context.upgradeLink();
  74. }
  75. CAutoBuffer Buf = SpObject2Buffer(Info);
  76. auto ret = pFunc->OnewayCall(FlowService_Method_DisallowControl, FlowService_MethodSignature_DisallowControl, Buf, m_context);
  77. m_context.clear();
  78. return ret;
  79. }
  80. ErrorCodeEnum ReturnAgent(FlowService_ReturnAgent_Info &Info)
  81. {
  82. CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
  83. if (m_context.checkEmpty())
  84. {
  85. m_context.AutoGenerate();
  86. DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
  87. m_context = m_context.upgradeLink();
  88. }
  89. CAutoBuffer Buf = SpObject2Buffer(Info);
  90. auto ret = pFunc->OnewayCall(FlowService_Method_ReturnAgent, FlowService_MethodSignature_ReturnAgent, Buf, m_context);
  91. m_context.clear();
  92. return ret;
  93. }
  94. ErrorCodeEnum SwitchToFrontFlow()
  95. {
  96. CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
  97. if (m_context.checkEmpty())
  98. {
  99. m_context.AutoGenerate();
  100. DbgToBeidou(m_context, m_pEntityBase != NULL ? m_pEntityBase->GetEntityName() : "")();
  101. m_context = m_context.upgradeLink();
  102. }
  103. auto ret = pFunc->OnewayCall(FlowService_Method_SwitchToFrontFlow, FlowService_MethodSignature_SwitchToFrontFlow, m_context);
  104. m_context.clear();
  105. return ret;
  106. }
  107. bool SafeDelete()
  108. {
  109. if (!m_bSysManaged) {
  110. delete this;
  111. }
  112. return m_bSysManaged;
  113. }
  114. protected:
  115. bool m_bSysManaged;
  116. CEntityBase *m_pEntityBase;
  117. linkContext m_context;
  118. bool bSessionClosed;
  119. };
  120. ///////////////////////////
  121. } // namespace InitiativeTransfer
  122. #endif // __INITIATIVETRANSFER_CLIENT_G_H