HelloService_client_g.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef __HELLOSERVICE_CLIENT_G_H
  2. #define __HELLOSERVICE_CLIENT_G_H
  3. #pragma once
  4. // This code is generated by spgen tool!
  5. #include "HelloService_def_g.h"
  6. namespace HelloService {
  7. class HelloService_ClientBase : public CClientSessionBase {
  8. public:
  9. HelloService_ClientBase(CEntityBase *pEntity) : m_pEntityBase(pEntity), m_bSysManaged(false) {}
  10. protected:
  11. virtual ~HelloService_ClientBase() {}
  12. public:
  13. ErrorCodeEnum Connect(CSmartPointer<IAsynWaitSp> &spAsyncWait)
  14. {
  15. CSmartPointer<IEntityFunction> pFunc = m_pEntityBase->GetFunction();
  16. ErrorCodeEnum Error = pFunc->ConnectRemoteEntity(this, "HelloService", "HelloService", spAsyncWait);
  17. if (Error == Error_Succeed) {
  18. Dbg("set m_bSysManaged true!");
  19. m_bSysManaged = true;
  20. }
  21. return Error;
  22. }
  23. ErrorCodeEnum Connect()
  24. {
  25. CSmartPointer<IAsynWaitSp> spAsyncWait;
  26. ErrorCodeEnum Error = Connect(spAsyncWait);
  27. if (Error == Error_Succeed) {
  28. Dbg("pre connect succeed, start to wait...");
  29. Error = spAsyncWait->WaitAnswer();
  30. }
  31. return Error;
  32. }
  33. ErrorCodeEnum Ping()
  34. {
  35. CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
  36. return pFunc->OnewayCall(HelloService_Method_Ping, HelloService_MethodSignature_Ping);
  37. }
  38. ErrorCodeEnum Hello(HelloService_Hello_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
  39. {
  40. CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
  41. CAutoBuffer Buf = SpObject2Buffer(Req);
  42. return pFunc->AsyncRequest(HelloService_Method_Hello, HelloService_MethodSignature_Hello, Buf, spAsyncWait, dwTimeout);
  43. }
  44. ErrorCodeEnum Hello(HelloService_Hello_Req &Req, HelloService_Hello_Ans &Ans, DWORD dwTimeout)
  45. {
  46. CSmartPointer<IAsynWaitSp> spAsyncWait;
  47. ErrorCodeEnum Error = Hello(Req, spAsyncWait, dwTimeout);
  48. if (Error == Error_Succeed) {
  49. bool bEnd = false;
  50. Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd);
  51. LOG_ASSERT(Error || bEnd);
  52. }
  53. return Error;
  54. }
  55. bool SafeDelete()
  56. {
  57. if (!m_bSysManaged) {
  58. delete this;
  59. }
  60. return m_bSysManaged;
  61. }
  62. protected:
  63. bool m_bSysManaged;
  64. CEntityBase *m_pEntityBase;
  65. };
  66. ///////////////////////////
  67. } // namespace HelloService
  68. #endif // __HELLOSERVICE_CLIENT_G_H