123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- #ifndef __SIPPHONE_SERVER_G_H
- #define __SIPPHONE_SERVER_G_H
- #pragma once
- // This code is generated by spgen tool!
- #include "SIPPhone_def_g.h"
- namespace SIPPhone {
- class PhoneService_ServerSessionBase : public CServerSessionBase
- {
- public:
- PhoneService_ServerSessionBase() { }
- virtual ~PhoneService_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 PhoneService_Method_MakeCall:
- if (dwSignature == PhoneService_MethodSignature_MakeCall) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_HangupCall:
- if (dwSignature == PhoneService_MethodSignature_HangupCall) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_StartVideo:
- if (dwSignature == PhoneService_MethodSignature_StartVideo) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_StopVideo:
- if (dwSignature == PhoneService_MethodSignature_StopVideo) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_RealErrorCheck:
- if (dwSignature == PhoneService_MethodSignature_RealErrorCheck) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_ReleaseCall:
- if (dwSignature == PhoneService_MethodSignature_ReleaseCall) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_BeginState:
- if (dwSignature == PhoneService_MethodSignature_BeginState) {
- bOverlap = false;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_EndState:
- if (dwSignature == PhoneService_MethodSignature_EndState) {
- bOverlap = true;
- } else {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_SetCallingParam:
- if (dwSignature == PhoneService_MethodSignature_SetCallingParam) {
- 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 PhoneService_Method_MakeCall:
- if (dwSignature != PhoneService_MethodSignature_MakeCall) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_HangupCall:
- if (dwSignature != PhoneService_MethodSignature_HangupCall) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_StartVideo:
- if (dwSignature != PhoneService_MethodSignature_StartVideo) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_StopVideo:
- if (dwSignature != PhoneService_MethodSignature_StopVideo) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_RealErrorCheck:
- if (dwSignature != PhoneService_MethodSignature_RealErrorCheck) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_ReleaseCall:
- if (dwSignature != PhoneService_MethodSignature_ReleaseCall) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_BeginState:
- if (dwSignature != PhoneService_MethodSignature_BeginState) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_EndState:
- if (dwSignature != PhoneService_MethodSignature_EndState) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- case PhoneService_Method_SetCallingParam:
- if (dwSignature != PhoneService_MethodSignature_SetCallingParam) {
- Error = Error_MethodSignatureFailed;
- }
- break;
- default:
- Error = Error_MethodNotFound;
- break;
- }
- return Error;
- }
- virtual void Handle_MakeCall(SpReqAnsContext<PhoneService_MakeCall_Req, PhoneService_MakeCall_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_HangupCall(SpReqAnsContext<PhoneService_HangupCall_Req, PhoneService_HangupCall_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_StartVideo(SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_StopVideo(SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_RealErrorCheck(SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_ReleaseCall(SpReqAnsContext<PhoneService_ReleaseCall_Req, PhoneService_ReleaseCall_Ans>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_BeginState(SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_EndState(SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx)
- {
- /// override by user
- }
- virtual void Handle_SetCallingParam(SpOnewayCallContext<PhoneService_SetCallingParam_Info>::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 PhoneService_Method_MakeCall:
- {
- SpReqAnsContext<PhoneService_MakeCall_Req,PhoneService_MakeCall_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<PhoneService_MakeCall_Req,PhoneService_MakeCall_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_MakeCall(ctx);
- }
- break;
- case PhoneService_Method_HangupCall:
- {
- SpReqAnsContext<PhoneService_HangupCall_Req,PhoneService_HangupCall_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<PhoneService_HangupCall_Req,PhoneService_HangupCall_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_HangupCall(ctx);
- }
- break;
- case PhoneService_Method_StartVideo:
- {
- SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx;
- ctx.Attach(new SpOnewayCallContext<PhoneService_StartVideo_Info>());
- SpBuffer2Object(Buf, ctx->Info);
- Handle_StartVideo(ctx);
- }
- break;
- case PhoneService_Method_StopVideo:
- {
- SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx;
- ctx.Attach(new SpOnewayCallContext<PhoneService_StopVideo_Info>());
- SpBuffer2Object(Buf, ctx->Info);
- Handle_StopVideo(ctx);
- }
- break;
- case PhoneService_Method_RealErrorCheck:
- {
- SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx;
- ctx.Attach(new SpOnewayCallContext<PhoneService_RealErrorCheck_Info>());
- SpBuffer2Object(Buf, ctx->Info);
- Handle_RealErrorCheck(ctx);
- }
- break;
- case PhoneService_Method_ReleaseCall:
- {
- SpReqAnsContext<PhoneService_ReleaseCall_Req,PhoneService_ReleaseCall_Ans>::Pointer ctx;
- ctx.Attach(new SpReqAnsContext<PhoneService_ReleaseCall_Req,PhoneService_ReleaseCall_Ans>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_ReleaseCall(ctx);
- }
- break;
- case PhoneService_Method_BeginState:
- {
- SpSubscribeContext<PhoneService_BeginState_Sub,PhoneService_PhoneState_Info>::Pointer ctx;
- ctx.Attach(new SpSubscribeContext<PhoneService_BeginState_Sub,PhoneService_PhoneState_Info>(pTransactionContext));
- SpBuffer2Object(Buf, ctx->Req);
- Handle_BeginState(ctx);
- }
- break;
- case PhoneService_Method_EndState:
- {
- SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx;
- ctx.Attach(new SpOnewayCallContext<PhoneService_EndState_Info>());
- SpBuffer2Object(Buf, ctx->Info);
- Handle_EndState(ctx);
- }
- break;
- case PhoneService_Method_SetCallingParam:
- {
- SpOnewayCallContext<PhoneService_SetCallingParam_Info>::Pointer ctx;
- ctx.Attach(new SpOnewayCallContext<PhoneService_SetCallingParam_Info>());
- SpBuffer2Object(Buf, ctx->Info);
- Handle_SetCallingParam(ctx);
- }
- break;
- default:
- assert(0);
- break;
- }
-
- } else {
- pTransactionContext->SendAnswer(Error);
- }
- }
- };
- ///////////////////////////
- } // namespace SIPPhone
- #endif // __SIPPHONE_SERVER_G_H
|