Recorder_server_g.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef __RECORDER_SERVER_G_H
  2. #define __RECORDER_SERVER_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "Recorder_def_g.h"
  6. namespace Recorder
  7. {
  8. class RecorderSerVice_ServerSessionBase : public CServerSessionBase
  9. {
  10. public:
  11. RecorderSerVice_ServerSessionBase()
  12. {
  13. /// override by user
  14. }
  15. virtual ~RecorderSerVice_ServerSessionBase()
  16. {
  17. /// override by user
  18. }
  19. virtual bool IsExclusive() { return false; }
  20. virtual bool IsSessionOverlap() { return true; }
  21. virtual ErrorCodeEnum GetMessageAttr(DWORD dwMessageID, DWORD dwSignature, bool& bOverlap)
  22. {
  23. ErrorCodeEnum Error = Error_Succeed;
  24. switch (dwMessageID) {
  25. case RecorderSerVice_Method_StartTransactionRecord:
  26. if (dwSignature == RecorderSerVice_MethodSignature_StartTransactionRecord) {
  27. bOverlap = true;
  28. } else {
  29. Error = Error_MethodSignatureFailed;
  30. }
  31. break;
  32. case RecorderSerVice_Method_StopTransactionRecord:
  33. if (dwSignature == RecorderSerVice_MethodSignature_StopTransactionRecord) {
  34. bOverlap = true;
  35. } else {
  36. Error = Error_MethodSignatureFailed;
  37. }
  38. break;
  39. default:
  40. Error = Error_MethodNotFound;
  41. break;
  42. }
  43. return Error;
  44. }
  45. int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
  46. {
  47. ErrorCodeEnum Error = Error_Succeed;
  48. switch (dwMessageID) {
  49. case RecorderSerVice_Method_StartTransactionRecord:
  50. if (dwSignature != RecorderSerVice_MethodSignature_StartTransactionRecord) {
  51. Error = Error_MethodSignatureFailed;
  52. }
  53. break;
  54. case RecorderSerVice_Method_StopTransactionRecord:
  55. if (dwSignature != RecorderSerVice_MethodSignature_StopTransactionRecord) {
  56. Error = Error_MethodSignatureFailed;
  57. }
  58. break;
  59. default:
  60. Error = Error_MethodNotFound;
  61. break;
  62. }
  63. return Error;
  64. }
  65. virtual void Handle_StartTransactionRecord(SpReqAnsContext<RecorderSerVice_StartTransactionRecord_Req, RecorderSerVice_StartTransactionRecord_Ans>::Pointer ctx)
  66. {
  67. /// override by user
  68. }
  69. virtual void Handle_StopTransactionRecord(SpReqAnsContext<RecorderSerVice_StopTransactionRecord_Req, RecorderSerVice_StopTransactionRecord_Ans>::Pointer ctx)
  70. {
  71. /// override by user
  72. }
  73. virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
  74. {
  75. CAutoBuffer Buf;
  76. DWORD dwMessageID;
  77. DWORD dwMessageSignature;
  78. ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
  79. if (Error == Error_Succeed) {
  80. #ifdef DEBUG
  81. assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
  82. #else
  83. if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
  84. pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
  85. return;
  86. }
  87. #endif
  88. switch (dwMessageID) {
  89. case RecorderSerVice_Method_StartTransactionRecord:
  90. {
  91. SpReqAnsContext<RecorderSerVice_StartTransactionRecord_Req, RecorderSerVice_StartTransactionRecord_Ans>::Pointer ctx;
  92. ctx.Attach(new SpReqAnsContext<RecorderSerVice_StartTransactionRecord_Req, RecorderSerVice_StartTransactionRecord_Ans>(pTransactionContext));
  93. SpBuffer2Object(Buf, ctx->Req);
  94. pTransactionContext->GetLinkContext(ctx->link);
  95. Handle_StartTransactionRecord(ctx);
  96. }
  97. break;
  98. case RecorderSerVice_Method_StopTransactionRecord:
  99. {
  100. SpReqAnsContext<RecorderSerVice_StopTransactionRecord_Req, RecorderSerVice_StopTransactionRecord_Ans>::Pointer ctx;
  101. ctx.Attach(new SpReqAnsContext<RecorderSerVice_StopTransactionRecord_Req, RecorderSerVice_StopTransactionRecord_Ans>(pTransactionContext));
  102. SpBuffer2Object(Buf, ctx->Req);
  103. pTransactionContext->GetLinkContext(ctx->link);
  104. Handle_StopTransactionRecord(ctx);
  105. }
  106. break;
  107. default:
  108. assert(0);
  109. break;
  110. }
  111. } else {
  112. pTransactionContext->SendAnswer(Error);
  113. }
  114. }
  115. };
  116. ///////////////////////////
  117. } // namespace Recorder
  118. #endif // __RECORDER_SERVER_G_H