#ifndef __LIVENESSDETECTION_SERVER_G_H #define __LIVENESSDETECTION_SERVER_G_H #pragma once // This code is generated by spgen tool! #include "LivenessDetection_def_g.h" namespace LivenessDetection { class LivenessDetectionService_ServerSessionBase : public CServerSessionBase { public: LivenessDetectionService_ServerSessionBase() { /// override by user } virtual ~LivenessDetectionService_ServerSessionBase() { /// override by user } 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 LivenessDetectionService_Method_StartLivenessDetection: if (dwSignature == LivenessDetectionService_MethodSignature_StartLivenessDetection) { bOverlap = true; } else { Error = Error_MethodSignatureFailed; } break; case LivenessDetectionService_Method_StopLivenessDetection: if (dwSignature == LivenessDetectionService_MethodSignature_StopLivenessDetection) { 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 LivenessDetectionService_Method_StartLivenessDetection: if (dwSignature != LivenessDetectionService_MethodSignature_StartLivenessDetection) { Error = Error_MethodSignatureFailed; } break; case LivenessDetectionService_Method_StopLivenessDetection: if (dwSignature != LivenessDetectionService_MethodSignature_StopLivenessDetection) { Error = Error_MethodSignatureFailed; } break; default: Error = Error_MethodNotFound; break; } return Error; } virtual void Handle_StartLivenessDetection(SpReqAnsContext::Pointer ctx) { /// override by user } virtual void Handle_StopLivenessDetection(SpReqAnsContext::Pointer ctx) { /// override by user } virtual void OnRequest(CSmartPointer 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 LivenessDetectionService_Method_StartLivenessDetection: { SpReqAnsContext::Pointer ctx; ctx.Attach(new SpReqAnsContext(pTransactionContext)); SpBuffer2Object(Buf, ctx->Req); pTransactionContext->GetLinkContext(ctx->link); EntityResource::setLink(ctx->link); Handle_StartLivenessDetection(ctx); } break; case LivenessDetectionService_Method_StopLivenessDetection: { SpReqAnsContext::Pointer ctx; ctx.Attach(new SpReqAnsContext(pTransactionContext)); SpBuffer2Object(Buf, ctx->Req); pTransactionContext->GetLinkContext(ctx->link); EntityResource::setLink(ctx->link); Handle_StopLivenessDetection(ctx); } break; default: assert(0); break; } } else { pTransactionContext->SendAnswer(Error); } } }; /////////////////////////// } // namespace LivenessDetection #endif // __LIVENESSDETECTION_SERVER_G_H