#ifndef __MEDIACONTROLLER_SERVER_G_H #define __MEDIACONTROLLER_SERVER_G_H #pragma once // This code is generated by spgen tool! #include "MediaController_def_g.h" namespace MediaController { class MediaService_ServerSessionBase : public CServerSessionBase { public: MediaService_ServerSessionBase() { /// override by user } virtual ~MediaService_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 MediaService_Method_GetVideoDeviceName: if (dwSignature == MediaService_MethodSignature_GetVideoDeviceName) { bOverlap = true; } else { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StartCamera: if (dwSignature == MediaService_MethodSignature_StartCamera) { bOverlap = true; } else { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StopCamera: if (dwSignature == MediaService_MethodSignature_StopCamera) { bOverlap = true; } else { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StartEnvCamera: if (dwSignature == MediaService_MethodSignature_StartEnvCamera) { bOverlap = true; } else { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StopEnvCamera: if (dwSignature == MediaService_MethodSignature_StopEnvCamera) { bOverlap = true; } else { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StartSpeakerRender: if (dwSignature == MediaService_MethodSignature_StartSpeakerRender) { bOverlap = true; } else { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StopSpeakerRender: if (dwSignature == MediaService_MethodSignature_StopSpeakerRender) { 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 MediaService_Method_GetVideoDeviceName: if (dwSignature != MediaService_MethodSignature_GetVideoDeviceName) { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StartCamera: if (dwSignature != MediaService_MethodSignature_StartCamera) { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StopCamera: if (dwSignature != MediaService_MethodSignature_StopCamera) { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StartEnvCamera: if (dwSignature != MediaService_MethodSignature_StartEnvCamera) { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StopEnvCamera: if (dwSignature != MediaService_MethodSignature_StopEnvCamera) { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StartSpeakerRender: if (dwSignature != MediaService_MethodSignature_StartSpeakerRender) { Error = Error_MethodSignatureFailed; } break; case MediaService_Method_StopSpeakerRender: if (dwSignature != MediaService_MethodSignature_StopSpeakerRender) { Error = Error_MethodSignatureFailed; } break; default: Error = Error_MethodNotFound; break; } return Error; } virtual void Handle_GetVideoDeviceName(SpReqAnsContext::Pointer ctx) { /// override by user } virtual void Handle_StartCamera(SpOnewayCallContext::Pointer ctx) { /// override by user } virtual void Handle_StopCamera(SpOnewayCallContext::Pointer ctx) { /// override by user } virtual void Handle_StartEnvCamera(SpReqAnsContext::Pointer ctx) { /// override by user } virtual void Handle_StopEnvCamera(SpOnewayCallContext::Pointer ctx) { /// override by user } virtual void Handle_StartSpeakerRender(SpOnewayCallContext::Pointer ctx) { /// override by user } virtual void Handle_StopSpeakerRender(SpOnewayCallContext::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 MediaService_Method_GetVideoDeviceName: { SpReqAnsContext::Pointer ctx; ctx.Attach(new SpReqAnsContext(pTransactionContext)); SpBuffer2Object(Buf, ctx->Req); pTransactionContext->GetLinkContext(ctx->link); EntityResource::setLink(ctx->link); Handle_GetVideoDeviceName(ctx); } break; case MediaService_Method_StartCamera: { SpOnewayCallContext::Pointer ctx; ctx.Attach(new SpOnewayCallContext()); SpBuffer2Object(Buf, ctx->Info); pTransactionContext->GetLinkContext(ctx->link); EntityResource::setLink(ctx->link); Handle_StartCamera(ctx); } break; case MediaService_Method_StopCamera: { SpOnewayCallContext::Pointer ctx; ctx.Attach(new SpOnewayCallContext()); SpBuffer2Object(Buf, ctx->Info); pTransactionContext->GetLinkContext(ctx->link); EntityResource::setLink(ctx->link); Handle_StopCamera(ctx); } break; case MediaService_Method_StartEnvCamera: { SpReqAnsContext::Pointer ctx; ctx.Attach(new SpReqAnsContext(pTransactionContext)); SpBuffer2Object(Buf, ctx->Req); pTransactionContext->GetLinkContext(ctx->link); EntityResource::setLink(ctx->link); Handle_StartEnvCamera(ctx); } break; case MediaService_Method_StopEnvCamera: { SpOnewayCallContext::Pointer ctx; ctx.Attach(new SpOnewayCallContext()); SpBuffer2Object(Buf, ctx->Info); pTransactionContext->GetLinkContext(ctx->link); EntityResource::setLink(ctx->link); Handle_StopEnvCamera(ctx); } break; case MediaService_Method_StartSpeakerRender: { SpOnewayCallContext::Pointer ctx; ctx.Attach(new SpOnewayCallContext()); SpBuffer2Object(Buf, ctx->Info); pTransactionContext->GetLinkContext(ctx->link); EntityResource::setLink(ctx->link); Handle_StartSpeakerRender(ctx); } break; case MediaService_Method_StopSpeakerRender: { SpOnewayCallContext::Pointer ctx; ctx.Attach(new SpOnewayCallContext()); SpBuffer2Object(Buf, ctx->Info); pTransactionContext->GetLinkContext(ctx->link); EntityResource::setLink(ctx->link); Handle_StopSpeakerRender(ctx); } break; default: assert(0); break; } } else { pTransactionContext->SendAnswer(Error); } } }; /////////////////////////// } // namespace MediaController #endif // __MEDIACONTROLLER_SERVER_G_H