InitiativeTransfer_server_g.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #ifndef __INITIATIVETRANSFER_SERVER_G_H
  2. #define __INITIATIVETRANSFER_SERVER_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_ServerSessionBase : public CServerSessionBase
  8. {
  9. public:
  10. FlowService_ServerSessionBase()
  11. {
  12. /// override by user
  13. }
  14. virtual ~FlowService_ServerSessionBase()
  15. {
  16. /// override by user
  17. }
  18. virtual bool IsExclusive() { return false; }
  19. virtual bool IsSessionOverlap() { return true; }
  20. virtual ErrorCodeEnum GetMessageAttr(DWORD dwMessageID, DWORD dwSignature, bool &bOverlap)
  21. {
  22. ErrorCodeEnum Error = Error_Succeed;
  23. switch (dwMessageID) {
  24. case FlowService_Method_SwitchToAgentFlow:
  25. if (dwSignature == FlowService_MethodSignature_SwitchToAgentFlow) {
  26. bOverlap = true;
  27. } else {
  28. Error = Error_MethodSignatureFailed;
  29. }
  30. break;
  31. case FlowService_Method_DisallowControl:
  32. if (dwSignature == FlowService_MethodSignature_DisallowControl) {
  33. bOverlap = true;
  34. } else {
  35. Error = Error_MethodSignatureFailed;
  36. }
  37. break;
  38. case FlowService_Method_ReturnAgent:
  39. if (dwSignature == FlowService_MethodSignature_ReturnAgent) {
  40. bOverlap = true;
  41. } else {
  42. Error = Error_MethodSignatureFailed;
  43. }
  44. break;
  45. case FlowService_Method_SwitchToFrontFlow:
  46. if (dwSignature == FlowService_MethodSignature_SwitchToFrontFlow) {
  47. bOverlap = true;
  48. } else {
  49. Error = Error_MethodSignatureFailed;
  50. }
  51. break;
  52. default:
  53. Error = Error_MethodNotFound;
  54. break;
  55. }
  56. return Error;
  57. }
  58. int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
  59. {
  60. ErrorCodeEnum Error = Error_Succeed;
  61. switch (dwMessageID) {
  62. case FlowService_Method_SwitchToAgentFlow:
  63. if (dwSignature != FlowService_MethodSignature_SwitchToAgentFlow) {
  64. Error = Error_MethodSignatureFailed;
  65. }
  66. break;
  67. case FlowService_Method_DisallowControl:
  68. if (dwSignature != FlowService_MethodSignature_DisallowControl) {
  69. Error = Error_MethodSignatureFailed;
  70. }
  71. break;
  72. case FlowService_Method_ReturnAgent:
  73. if (dwSignature != FlowService_MethodSignature_ReturnAgent) {
  74. Error = Error_MethodSignatureFailed;
  75. }
  76. break;
  77. case FlowService_Method_SwitchToFrontFlow:
  78. if (dwSignature != FlowService_MethodSignature_SwitchToFrontFlow) {
  79. Error = Error_MethodSignatureFailed;
  80. }
  81. break;
  82. default:
  83. Error = Error_MethodNotFound;
  84. break;
  85. }
  86. return Error;
  87. }
  88. virtual void Handle_SwitchToAgentFlow(SpOnewayCallContext<FlowService_SwitchToAgentFlow_Info>::Pointer ctx)
  89. {
  90. /// override by user
  91. }
  92. virtual void Handle_DisallowControl(SpOnewayCallContext<FlowService_DisallowControl_Info>::Pointer ctx)
  93. {
  94. /// override by user
  95. }
  96. virtual void Handle_ReturnAgent(SpOnewayCallContext<FlowService_ReturnAgent_Info>::Pointer ctx)
  97. {
  98. /// override by user
  99. }
  100. virtual void Handle_SwitchToFrontFlow(SpOnewayCallContext<FlowService_SwitchToFrontFlow_Info>::Pointer ctx)
  101. {
  102. /// override by user
  103. }
  104. virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
  105. {
  106. CAutoBuffer Buf;
  107. DWORD dwMessageID;
  108. DWORD dwMessageSignature;
  109. ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
  110. if (Error == Error_Succeed) {
  111. #ifdef DEBUG
  112. assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
  113. #else
  114. if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
  115. pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
  116. return;
  117. }
  118. #endif
  119. switch (dwMessageID) {
  120. case FlowService_Method_SwitchToAgentFlow:
  121. {
  122. SpOnewayCallContext<FlowService_SwitchToAgentFlow_Info>::Pointer ctx;
  123. ctx.Attach(new SpOnewayCallContext<FlowService_SwitchToAgentFlow_Info>());
  124. SpBuffer2Object(Buf, ctx->Info);
  125. pTransactionContext->GetLinkContext(ctx->link);
  126. EntityResource::setLink(ctx->link);
  127. Handle_SwitchToAgentFlow(ctx);
  128. }
  129. break;
  130. case FlowService_Method_DisallowControl:
  131. {
  132. SpOnewayCallContext<FlowService_DisallowControl_Info>::Pointer ctx;
  133. ctx.Attach(new SpOnewayCallContext<FlowService_DisallowControl_Info>());
  134. SpBuffer2Object(Buf, ctx->Info);
  135. pTransactionContext->GetLinkContext(ctx->link);
  136. EntityResource::setLink(ctx->link);
  137. Handle_DisallowControl(ctx);
  138. }
  139. break;
  140. case FlowService_Method_ReturnAgent:
  141. {
  142. SpOnewayCallContext<FlowService_ReturnAgent_Info>::Pointer ctx;
  143. ctx.Attach(new SpOnewayCallContext<FlowService_ReturnAgent_Info>());
  144. SpBuffer2Object(Buf, ctx->Info);
  145. pTransactionContext->GetLinkContext(ctx->link);
  146. EntityResource::setLink(ctx->link);
  147. Handle_ReturnAgent(ctx);
  148. }
  149. break;
  150. case FlowService_Method_SwitchToFrontFlow:
  151. {
  152. SpOnewayCallContext<FlowService_SwitchToFrontFlow_Info>::Pointer ctx;
  153. ctx.Attach(new SpOnewayCallContext<FlowService_SwitchToFrontFlow_Info>());
  154. SpBuffer2Object(Buf, ctx->Info);
  155. pTransactionContext->GetLinkContext(ctx->link);
  156. EntityResource::setLink(ctx->link);
  157. Handle_SwitchToFrontFlow(ctx);
  158. }
  159. break;
  160. default:
  161. assert(0);
  162. break;
  163. }
  164. } else {
  165. pTransactionContext->SendAnswer(Error);
  166. }
  167. }
  168. };
  169. ///////////////////////////
  170. } // namespace InitiativeTransfer
  171. #endif // __INITIATIVETRANSFER_SERVER_G_H