| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- #ifndef __DOWNLOAD_SERVER_G_H
- #define __DOWNLOAD_SERVER_G_H
- #pragma once
- // This code is generated by spgen tool!
- #include "Download_def_g.h"
- namespace Download {
- class DownloadService_ServerSessionBase : public CServerSessionBase
- {
- public:
- DownloadService_ServerSessionBase() { }
- virtual ~DownloadService_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 DownloadService_Method_DownloadFile:
- if (dwSignature == DownloadService_MethodSignature_DownloadFile) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case DownloadService_Method_IsDownloading:
- if (dwSignature == DownloadService_MethodSignature_IsDownloading) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case DownloadService_Method_CancelDownloadFile:
- if (dwSignature == DownloadService_MethodSignature_CancelDownloadFile) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case DownloadService_Method_QueryDownloadState:
- if (dwSignature == DownloadService_MethodSignature_QueryDownloadState) {
- 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 DownloadService_Method_DownloadFile:
- if (dwSignature != DownloadService_MethodSignature_DownloadFile) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case DownloadService_Method_IsDownloading:
- if (dwSignature != DownloadService_MethodSignature_IsDownloading) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case DownloadService_Method_CancelDownloadFile:
- if (dwSignature != DownloadService_MethodSignature_CancelDownloadFile) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case DownloadService_Method_QueryDownloadState:
- if (dwSignature != DownloadService_MethodSignature_QueryDownloadState) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- default:
- Error = Error_MethodNotFound;
- break;
- }
- return Error;
- }
- virtual void Handle_DownloadFile(SpReqAnsContext<DownloadService_DownloadFile_Req, DownloadService_DownloadFile_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_IsDownloading(SpReqAnsContext<DownloadService_IsDownloading_Req, DownloadService_IsDownloading_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_CancelDownloadFile(SpReqAnsContext<DownloadService_CancelDownloadFile_Req, DownloadService_CancelDownloadFile_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_QueryDownloadState(SpReqAnsContext<DownloadService_QueryDownloadState_Req, DownloadService_QueryDownloadState_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 DownloadService_Method_DownloadFile:
- {
- SpReqAnsContext<DownloadService_DownloadFile_Req,DownloadService_DownloadFile_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<DownloadService_DownloadFile_Req,DownloadService_DownloadFile_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_DownloadFile(ctx);
- }
- break;
- case DownloadService_Method_IsDownloading:
- {
- SpReqAnsContext<DownloadService_IsDownloading_Req,DownloadService_IsDownloading_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<DownloadService_IsDownloading_Req,DownloadService_IsDownloading_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_IsDownloading(ctx);
- }
- break;
- case DownloadService_Method_CancelDownloadFile:
- {
- SpReqAnsContext<DownloadService_CancelDownloadFile_Req,DownloadService_CancelDownloadFile_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<DownloadService_CancelDownloadFile_Req,DownloadService_CancelDownloadFile_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_CancelDownloadFile(ctx);
- }
- break;
- case DownloadService_Method_QueryDownloadState:
- {
- SpReqAnsContext<DownloadService_QueryDownloadState_Req,DownloadService_QueryDownloadState_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<DownloadService_QueryDownloadState_Req,DownloadService_QueryDownloadState_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_QueryDownloadState(ctx);
- }
- break;
- default:
- assert(0);
- break;
- }
-
- } else {
- pTransactionContext->SendAnswer(Error);
- }
- }
- };
- ///////////////////////////
- } // namespace Download
- #endif // __DOWNLOAD_SERVER_G_H
|