Sensors_server_g.h 3.4 KB

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