123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- #ifndef __UPS_SERVER_G_H
- #define __UPS_SERVER_G_H
- #pragma once
- // This code is generated by spgen tool!
- #include "Ups_def_g.h"
- namespace Ups {
- class UpsService_ServerSessionBase : public CServerSessionBase
- {
- public:
- UpsService_ServerSessionBase() { }
- virtual ~UpsService_ServerSessionBase() { }
- virtual bool IsExclusive() { return false; }
- virtual bool IsSessionOverlap() { return true; }
- virtual ErrorCodeEnum GetMessageAttr(DWORD dwMessageID, DWORD dwSignature, bool &bOverlap)
- {
- ErrorCodeEnum Error = Error_Succeed;
- switch (dwMessageID) {
- case UpsService_Method_Open:
- if (dwSignature == UpsService_MethodSignature_Open) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case UpsService_Method_GetStatus:
- if (dwSignature == UpsService_MethodSignature_GetStatus) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case UpsService_Method_Shutdown:
- if (dwSignature == UpsService_MethodSignature_Shutdown) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case UpsService_Method_Close:
- if (dwSignature == UpsService_MethodSignature_Close) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- default:
- Error = Error_MethodNotFound;
- break;
- }
- return Error;
- }
- int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
- {
- ErrorCodeEnum Error = Error_Succeed;
- switch (dwMessageID) {
- case UpsService_Method_Open:
- if (dwSignature != UpsService_MethodSignature_Open) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case UpsService_Method_GetStatus:
- if (dwSignature != UpsService_MethodSignature_GetStatus) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case UpsService_Method_Shutdown:
- if (dwSignature != UpsService_MethodSignature_Shutdown) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case UpsService_Method_Close:
- if (dwSignature != UpsService_MethodSignature_Close) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- default:
- Error = Error_MethodNotFound;
- break;
- }
- return Error;
- }
- virtual void Handle_Open(SpReqAnsContext<UpsService_Open_Req, UpsService_Open_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_GetStatus(SpReqAnsContext<UpsService_GetStatus_Req, UpsService_GetStatus_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_Shutdown(SpReqAnsContext<UpsService_Shutdown_Req, UpsService_Shutdown_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_Close(SpReqAnsContext<UpsService_Close_Req, UpsService_Close_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
- {
- CAutoBuffer Buf;
- DWORD dwMessageID;
- DWORD dwMessageSignature;
- ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
- if (Error == Error_Succeed) {
- #ifdef DEBUG
- assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
- #else
- if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
- pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
- return;
- }
- #endif
- switch (dwMessageID) {
- case UpsService_Method_Open:
- {
- SpReqAnsContext<UpsService_Open_Req,UpsService_Open_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<UpsService_Open_Req,UpsService_Open_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_Open(ctx);
- }
- break;
- case UpsService_Method_GetStatus:
- {
- SpReqAnsContext<UpsService_GetStatus_Req,UpsService_GetStatus_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<UpsService_GetStatus_Req,UpsService_GetStatus_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_GetStatus(ctx);
- }
- break;
- case UpsService_Method_Shutdown:
- {
- SpReqAnsContext<UpsService_Shutdown_Req,UpsService_Shutdown_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<UpsService_Shutdown_Req,UpsService_Shutdown_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_Shutdown(ctx);
- }
- break;
- case UpsService_Method_Close:
- {
- SpReqAnsContext<UpsService_Close_Req,UpsService_Close_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<UpsService_Close_Req,UpsService_Close_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_Close(ctx);
- }
- break;
- default:
- assert(0);
- break;
- }
-
- } else {
- pTransactionContext->SendAnswer(Error);
- }
- }
- };
- ///////////////////////////
- } // namespace Ups
- #endif // __UPS_SERVER_G_H
|