SIPPhone_server_g.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. #ifndef __SIPPHONE_SERVER_G_H
  2. #define __SIPPHONE_SERVER_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "SIPPhone_def_g.h"
  6. namespace SIPPhone {
  7. class PhoneService_ServerSessionBase : public CServerSessionBase
  8. {
  9. public:
  10. PhoneService_ServerSessionBase() { }
  11. virtual ~PhoneService_ServerSessionBase() { }
  12. virtual bool IsExclusive() { return false; }
  13. virtual bool IsSessionOverlap() { return true; }
  14. virtual ErrorCodeEnum GetMessageAttr(DWORD dwMessageID, DWORD dwSignature, bool &bOverlap)
  15. {
  16. ErrorCodeEnum Error = Error_Succeed;
  17. switch (dwMessageID) {
  18. case PhoneService_Method_MakeCall:
  19. if (dwSignature == PhoneService_MethodSignature_MakeCall) {
  20. bOverlap = true;
  21. } else {
  22. Error = Error_MethodSignatureFailed;
  23. }
  24. break;
  25. case PhoneService_Method_HangupCall:
  26. if (dwSignature == PhoneService_MethodSignature_HangupCall) {
  27. bOverlap = true;
  28. } else {
  29. Error = Error_MethodSignatureFailed;
  30. }
  31. break;
  32. case PhoneService_Method_StartVideo:
  33. if (dwSignature == PhoneService_MethodSignature_StartVideo) {
  34. bOverlap = true;
  35. } else {
  36. Error = Error_MethodSignatureFailed;
  37. }
  38. break;
  39. case PhoneService_Method_StopVideo:
  40. if (dwSignature == PhoneService_MethodSignature_StopVideo) {
  41. bOverlap = true;
  42. } else {
  43. Error = Error_MethodSignatureFailed;
  44. }
  45. break;
  46. case PhoneService_Method_RealErrorCheck:
  47. if (dwSignature == PhoneService_MethodSignature_RealErrorCheck) {
  48. bOverlap = true;
  49. } else {
  50. Error = Error_MethodSignatureFailed;
  51. }
  52. break;
  53. case PhoneService_Method_ReleaseCall:
  54. if (dwSignature == PhoneService_MethodSignature_ReleaseCall) {
  55. bOverlap = true;
  56. } else {
  57. Error = Error_MethodSignatureFailed;
  58. }
  59. break;
  60. case PhoneService_Method_BeginState:
  61. if (dwSignature == PhoneService_MethodSignature_BeginState) {
  62. bOverlap = false;
  63. } else {
  64. Error = Error_MethodSignatureFailed;
  65. }
  66. break;
  67. case PhoneService_Method_EndState:
  68. if (dwSignature == PhoneService_MethodSignature_EndState) {
  69. bOverlap = true;
  70. } else {
  71. Error = Error_MethodSignatureFailed;
  72. }
  73. break;
  74. case PhoneService_Method_SetCallingParam:
  75. if (dwSignature == PhoneService_MethodSignature_SetCallingParam) {
  76. bOverlap = true;
  77. } else {
  78. Error = Error_MethodSignatureFailed;
  79. }
  80. break;
  81. default:
  82. Error = Error_MethodNotFound;
  83. break;
  84. }
  85. return Error;
  86. }
  87. int CheckMessageSignature(DWORD dwMessageID, DWORD dwSignature)
  88. {
  89. ErrorCodeEnum Error = Error_Succeed;
  90. switch (dwMessageID) {
  91. case PhoneService_Method_MakeCall:
  92. if (dwSignature != PhoneService_MethodSignature_MakeCall) {
  93. Error = Error_MethodSignatureFailed;
  94. }
  95. break;
  96. case PhoneService_Method_HangupCall:
  97. if (dwSignature != PhoneService_MethodSignature_HangupCall) {
  98. Error = Error_MethodSignatureFailed;
  99. }
  100. break;
  101. case PhoneService_Method_StartVideo:
  102. if (dwSignature != PhoneService_MethodSignature_StartVideo) {
  103. Error = Error_MethodSignatureFailed;
  104. }
  105. break;
  106. case PhoneService_Method_StopVideo:
  107. if (dwSignature != PhoneService_MethodSignature_StopVideo) {
  108. Error = Error_MethodSignatureFailed;
  109. }
  110. break;
  111. case PhoneService_Method_RealErrorCheck:
  112. if (dwSignature != PhoneService_MethodSignature_RealErrorCheck) {
  113. Error = Error_MethodSignatureFailed;
  114. }
  115. break;
  116. case PhoneService_Method_ReleaseCall:
  117. if (dwSignature != PhoneService_MethodSignature_ReleaseCall) {
  118. Error = Error_MethodSignatureFailed;
  119. }
  120. break;
  121. case PhoneService_Method_BeginState:
  122. if (dwSignature != PhoneService_MethodSignature_BeginState) {
  123. Error = Error_MethodSignatureFailed;
  124. }
  125. break;
  126. case PhoneService_Method_EndState:
  127. if (dwSignature != PhoneService_MethodSignature_EndState) {
  128. Error = Error_MethodSignatureFailed;
  129. }
  130. break;
  131. case PhoneService_Method_SetCallingParam:
  132. if (dwSignature != PhoneService_MethodSignature_SetCallingParam) {
  133. Error = Error_MethodSignatureFailed;
  134. }
  135. break;
  136. default:
  137. Error = Error_MethodNotFound;
  138. break;
  139. }
  140. return Error;
  141. }
  142. virtual void Handle_MakeCall(SpReqAnsContext<PhoneService_MakeCall_Req, PhoneService_MakeCall_Ans>::Pointer ctx)
  143. {
  144. /// override by user
  145. }
  146. virtual void Handle_HangupCall(SpReqAnsContext<PhoneService_HangupCall_Req, PhoneService_HangupCall_Ans>::Pointer ctx)
  147. {
  148. /// override by user
  149. }
  150. virtual void Handle_StartVideo(SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx)
  151. {
  152. /// override by user
  153. }
  154. virtual void Handle_StopVideo(SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx)
  155. {
  156. /// override by user
  157. }
  158. virtual void Handle_RealErrorCheck(SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx)
  159. {
  160. /// override by user
  161. }
  162. virtual void Handle_ReleaseCall(SpReqAnsContext<PhoneService_ReleaseCall_Req, PhoneService_ReleaseCall_Ans>::Pointer ctx)
  163. {
  164. /// override by user
  165. }
  166. virtual void Handle_BeginState(SpSubscribeContext<PhoneService_BeginState_Sub, PhoneService_PhoneState_Info>::Pointer ctx)
  167. {
  168. /// override by user
  169. }
  170. virtual void Handle_EndState(SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx)
  171. {
  172. /// override by user
  173. }
  174. virtual void Handle_SetCallingParam(SpOnewayCallContext<PhoneService_SetCallingParam_Info>::Pointer ctx)
  175. {
  176. /// override by user
  177. }
  178. virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
  179. {
  180. CAutoBuffer Buf;
  181. DWORD dwMessageID;
  182. DWORD dwMessageSignature;
  183. ErrorCodeEnum Error = pTransactionContext->GetReceiveBuffer(dwMessageID, dwMessageSignature, Buf);
  184. if (Error == Error_Succeed) {
  185. #ifdef DEBUG
  186. assert(CheckMessageSignature(dwMessageID, dwMessageSignature) == Error_Succeed);
  187. #else
  188. if (CheckMessageSignature(dwMessageID, dwMessageSignature) != Error_Succeed) {
  189. pTransactionContext->SendAnswer(Error_MethodSignatureFailed);
  190. return;
  191. }
  192. #endif
  193. switch (dwMessageID) {
  194. case PhoneService_Method_MakeCall:
  195. {
  196. SpReqAnsContext<PhoneService_MakeCall_Req,PhoneService_MakeCall_Ans>::Pointer ctx;
  197. ctx.Attach(new SpReqAnsContext<PhoneService_MakeCall_Req,PhoneService_MakeCall_Ans>(pTransactionContext));
  198. SpBuffer2Object(Buf, ctx->Req);
  199. Handle_MakeCall(ctx);
  200. }
  201. break;
  202. case PhoneService_Method_HangupCall:
  203. {
  204. SpReqAnsContext<PhoneService_HangupCall_Req,PhoneService_HangupCall_Ans>::Pointer ctx;
  205. ctx.Attach(new SpReqAnsContext<PhoneService_HangupCall_Req,PhoneService_HangupCall_Ans>(pTransactionContext));
  206. SpBuffer2Object(Buf, ctx->Req);
  207. Handle_HangupCall(ctx);
  208. }
  209. break;
  210. case PhoneService_Method_StartVideo:
  211. {
  212. SpOnewayCallContext<PhoneService_StartVideo_Info>::Pointer ctx;
  213. ctx.Attach(new SpOnewayCallContext<PhoneService_StartVideo_Info>());
  214. SpBuffer2Object(Buf, ctx->Info);
  215. Handle_StartVideo(ctx);
  216. }
  217. break;
  218. case PhoneService_Method_StopVideo:
  219. {
  220. SpOnewayCallContext<PhoneService_StopVideo_Info>::Pointer ctx;
  221. ctx.Attach(new SpOnewayCallContext<PhoneService_StopVideo_Info>());
  222. SpBuffer2Object(Buf, ctx->Info);
  223. Handle_StopVideo(ctx);
  224. }
  225. break;
  226. case PhoneService_Method_RealErrorCheck:
  227. {
  228. SpOnewayCallContext<PhoneService_RealErrorCheck_Info>::Pointer ctx;
  229. ctx.Attach(new SpOnewayCallContext<PhoneService_RealErrorCheck_Info>());
  230. SpBuffer2Object(Buf, ctx->Info);
  231. Handle_RealErrorCheck(ctx);
  232. }
  233. break;
  234. case PhoneService_Method_ReleaseCall:
  235. {
  236. SpReqAnsContext<PhoneService_ReleaseCall_Req,PhoneService_ReleaseCall_Ans>::Pointer ctx;
  237. ctx.Attach(new SpReqAnsContext<PhoneService_ReleaseCall_Req,PhoneService_ReleaseCall_Ans>(pTransactionContext));
  238. SpBuffer2Object(Buf, ctx->Req);
  239. Handle_ReleaseCall(ctx);
  240. }
  241. break;
  242. case PhoneService_Method_BeginState:
  243. {
  244. SpSubscribeContext<PhoneService_BeginState_Sub,PhoneService_PhoneState_Info>::Pointer ctx;
  245. ctx.Attach(new SpSubscribeContext<PhoneService_BeginState_Sub,PhoneService_PhoneState_Info>(pTransactionContext));
  246. SpBuffer2Object(Buf, ctx->Req);
  247. Handle_BeginState(ctx);
  248. }
  249. break;
  250. case PhoneService_Method_EndState:
  251. {
  252. SpOnewayCallContext<PhoneService_EndState_Info>::Pointer ctx;
  253. ctx.Attach(new SpOnewayCallContext<PhoneService_EndState_Info>());
  254. SpBuffer2Object(Buf, ctx->Info);
  255. Handle_EndState(ctx);
  256. }
  257. break;
  258. case PhoneService_Method_SetCallingParam:
  259. {
  260. SpOnewayCallContext<PhoneService_SetCallingParam_Info>::Pointer ctx;
  261. ctx.Attach(new SpOnewayCallContext<PhoneService_SetCallingParam_Info>());
  262. SpBuffer2Object(Buf, ctx->Info);
  263. Handle_SetCallingParam(ctx);
  264. }
  265. break;
  266. default:
  267. assert(0);
  268. break;
  269. }
  270. } else {
  271. pTransactionContext->SendAnswer(Error);
  272. }
  273. }
  274. };
  275. ///////////////////////////
  276. } // namespace SIPPhone
  277. #endif // __SIPPHONE_SERVER_G_H