mod_rpc.cpp 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "stdafx.h"
  2. #include "SpBase.h"
  3. #include <winpr/synch.h>
  4. #include "guitask.h"
  5. class rpcClientEntity : public CEntityBase, public ITimerListener, public ISysVarListener
  6. {
  7. public:
  8. rpcClientEntity()
  9. {}
  10. virtual ~rpcClientEntity() {}
  11. virtual const char *GetEntityName() const { return "rpcClient"; }
  12. virtual void OnTimeout(DWORD dwTimerID){
  13. LOG_FUNCTION();
  14. }
  15. virtual void OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName){
  16. LOG_TRACE("entity:%s key:%s value:%s", pszEntityName, pszKey, pszValue);
  17. }
  18. virtual void OnStarted(){
  19. LOG_FUNCTION();
  20. g_task.Kickoff(this);
  21. //open server
  22. g_task.openrpcServer(9000);
  23. //entity Init
  24. auto rc = g_task.SubscribeLog();
  25. }
  26. virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext)
  27. {
  28. LOG_FUNCTION();
  29. pTransactionContext->SendAnswer(Error_Succeed);
  30. }
  31. private:
  32. };
  33. SP_BEGIN_ENTITY_MAP()
  34. SP_ENTITY(rpcClientEntity)
  35. SP_END_ENTITY_MAP()