123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- #ifndef __ASSISTANTCHANNEL_SERVER_G_H
- #define __ASSISTANTCHANNEL_SERVER_G_H
- #pragma once
- // This code is generated by spgen tool!
- #include "AssistantChannel_def_g.h"
- namespace AssistantChannel {
- class ChannelService_ServerSessionBase : public CServerSessionBase
- {
- public:
- ChannelService_ServerSessionBase()
- {
- /// override by user
- }
- virtual ~ChannelService_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 ChannelService_Method_Connect:
- if (dwSignature == ChannelService_MethodSignature_Connect) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_Close:
- if (dwSignature == ChannelService_MethodSignature_Close) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_GetState:
- if (dwSignature == ChannelService_MethodSignature_GetState) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_BeginState:
- if (dwSignature == ChannelService_MethodSignature_BeginState) {
- bOverlap = false;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_EndState:
- if (dwSignature == ChannelService_MethodSignature_EndState) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_Send:
- if (dwSignature == ChannelService_MethodSignature_Send) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_BeginRecv:
- if (dwSignature == ChannelService_MethodSignature_BeginRecv) {
- bOverlap = false;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_EndRecv:
- if (dwSignature == ChannelService_MethodSignature_EndRecv) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_GetIpByDomain:
- if (dwSignature == ChannelService_MethodSignature_GetIpByDomain) {
- 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 ChannelService_Method_Connect:
- if (dwSignature != ChannelService_MethodSignature_Connect) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_Close:
- if (dwSignature != ChannelService_MethodSignature_Close) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_GetState:
- if (dwSignature != ChannelService_MethodSignature_GetState) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_BeginState:
- if (dwSignature != ChannelService_MethodSignature_BeginState) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_EndState:
- if (dwSignature != ChannelService_MethodSignature_EndState) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_Send:
- if (dwSignature != ChannelService_MethodSignature_Send) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_BeginRecv:
- if (dwSignature != ChannelService_MethodSignature_BeginRecv) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_EndRecv:
- if (dwSignature != ChannelService_MethodSignature_EndRecv) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case ChannelService_Method_GetIpByDomain:
- if (dwSignature != ChannelService_MethodSignature_GetIpByDomain) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- default:
- Error = Error_MethodNotFound;
- break;
- }
- return Error;
- }
- virtual void Handle_Connect(SpReqAnsContext<ChannelService_Connect_Req, ChannelService_Connect_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_Close(SpReqAnsContext<ChannelService_Close_Req, ChannelService_Close_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_GetState(SpReqAnsContext<ChannelService_GetState_Req, ChannelService_GetState_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_BeginState(SpSubscribeContext<ChannelService_BeginState_Sub, ChannelService_State_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_EndState(SpOnewayCallContext<ChannelService_EndState_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_Send(SpOnewayCallContext<ChannelService_Send_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_BeginRecv(SpSubscribeContext<ChannelService_BeginRecv_Sub, ChannelService_Packet_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_EndRecv(SpOnewayCallContext<ChannelService_EndRecv_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_GetIpByDomain(SpReqAnsContext<ChannelService_GetIpByDomain_Req, ChannelService_GetIpByDomain_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 ChannelService_Method_Connect:
- {
- SpReqAnsContext<ChannelService_Connect_Req,ChannelService_Connect_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<ChannelService_Connect_Req,ChannelService_Connect_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- pTransactionContext->GetLinkContext(ctx->link);
- EntityResource::setLink(ctx->link);
- Handle_Connect(ctx);
- }
- break;
- case ChannelService_Method_Close:
- {
- SpReqAnsContext<ChannelService_Close_Req,ChannelService_Close_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<ChannelService_Close_Req,ChannelService_Close_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- pTransactionContext->GetLinkContext(ctx->link);
- EntityResource::setLink(ctx->link);
- Handle_Close(ctx);
- }
- break;
- case ChannelService_Method_GetState:
- {
- SpReqAnsContext<ChannelService_GetState_Req,ChannelService_GetState_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<ChannelService_GetState_Req,ChannelService_GetState_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- pTransactionContext->GetLinkContext(ctx->link);
- EntityResource::setLink(ctx->link);
- Handle_GetState(ctx);
- }
- break;
- case ChannelService_Method_BeginState:
- {
- SpSubscribeContext<ChannelService_BeginState_Sub,ChannelService_State_Info>::Pointer ctx;
- ctx.Attach(new SpSubscribeContext<ChannelService_BeginState_Sub,ChannelService_State_Info>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_BeginState(ctx);
- }
- break;
- case ChannelService_Method_EndState:
- {
- SpOnewayCallContext<ChannelService_EndState_Info>::Pointer ctx;
- ctx.Attach(new SpOnewayCallContext<ChannelService_EndState_Info>());
- SpBuffer2Object(Buf, ctx->Info);
- Handle_EndState(ctx);
- }
- break;
- case ChannelService_Method_Send:
- {
- SpOnewayCallContext<ChannelService_Send_Info>::Pointer ctx;
- ctx.Attach(new SpOnewayCallContext<ChannelService_Send_Info>());
- SpBuffer2Object(Buf, ctx->Info);
- pTransactionContext->GetLinkContext(ctx->link);
- EntityResource::setLink(ctx->link);
- Handle_Send(ctx);
- }
- break;
- case ChannelService_Method_BeginRecv:
- {
- SpSubscribeContext<ChannelService_BeginRecv_Sub,ChannelService_Packet_Info>::Pointer ctx;
- ctx.Attach(new SpSubscribeContext<ChannelService_BeginRecv_Sub,ChannelService_Packet_Info>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_BeginRecv(ctx);
- }
- break;
- case ChannelService_Method_EndRecv:
- {
- SpOnewayCallContext<ChannelService_EndRecv_Info>::Pointer ctx;
- ctx.Attach(new SpOnewayCallContext<ChannelService_EndRecv_Info>());
- SpBuffer2Object(Buf, ctx->Info);
- Handle_EndRecv(ctx);
- }
- break;
- case ChannelService_Method_GetIpByDomain:
- {
- SpReqAnsContext<ChannelService_GetIpByDomain_Req,ChannelService_GetIpByDomain_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<ChannelService_GetIpByDomain_Req,ChannelService_GetIpByDomain_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- pTransactionContext->GetLinkContext(ctx->link);
- EntityResource::setLink(ctx->link);
- Handle_GetIpByDomain(ctx);
- }
- break;
- default:
- assert(0);
- break;
- }
-
- } else {
- pTransactionContext->SendAnswer(Error);
- }
- }
- };
- ///////////////////////////
- } // namespace AssistantChannel
- #endif // __ASSISTANTCHANNEL_SERVER_G_H
|