EsmeReceiverCom.h
上传用户:hkcoast
上传日期:2007-01-12
资源大小:979k
文件大小:2k
源码类别:

手机短信编程

开发平台:

Visual C++

  1. // EsmeReceiverCom.h : Declaration of the CEsmeReceiverCom
  2. #pragma once
  3. #include "resource.h"       // main symbols
  4. #include "SMPPCOM.h"
  5. #include "_IEsmeReceiverComEvents_CP.h"
  6. #include "..smpppacket.h"
  7. #include "..EsmeReceiver.h"
  8. // CEsmeReceiverCom
  9. class ATL_NO_VTABLE CEsmeReceiverCom : public CEsmeReceiver,
  10. public CComObjectRootEx<CComSingleThreadModel>,
  11. public CComCoClass<CEsmeReceiverCom, &CLSID_EsmeReceiverCom>,
  12. public IConnectionPointContainerImpl<CEsmeReceiverCom>,
  13. public CProxy_IEsmeReceiverComEvents<CEsmeReceiverCom>, 
  14. public IDispatchImpl<IEsmeReceiverCom, &IID_IEsmeReceiverCom, &LIBID_SMPPCOMLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
  15. {
  16. public:
  17. CEsmeReceiverCom()
  18. {
  19. m_response_event = CreateEvent(NULL, TRUE, FALSE, NULL);
  20. InitializeCriticalSection(&m_cs);
  21. //register callback handle function to processing receiving packets
  22. registerProcessPacket(processPacketProc, this);
  23. }
  24. ~CEsmeReceiverCom()
  25. {
  26. CloseHandle(m_response_event);
  27. DeleteCriticalSection(&m_cs);
  28. }
  29. DECLARE_REGISTRY_RESOURCEID(IDR_ESMERECEIVERCOM)
  30. DECLARE_NOT_AGGREGATABLE(CEsmeReceiverCom)
  31. BEGIN_COM_MAP(CEsmeReceiverCom)
  32. COM_INTERFACE_ENTRY(IEsmeReceiverCom)
  33. COM_INTERFACE_ENTRY(IDispatch)
  34. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  35. END_COM_MAP()
  36. BEGIN_CONNECTION_POINT_MAP(CEsmeReceiverCom)
  37. CONNECTION_POINT_ENTRY(__uuidof(_IEsmeReceiverComEvents))
  38. END_CONNECTION_POINT_MAP()
  39. DECLARE_PROTECT_FINAL_CONSTRUCT()
  40. HRESULT FinalConstruct()
  41. {
  42. return S_OK;
  43. }
  44. void FinalRelease() 
  45. {
  46. }
  47. public:
  48. STDMETHOD(bind)(BSTR sysid, BSTR passwd, BSTR systype, ISmppAddressCom* iaddr, VARIANT_BOOL* pret);
  49. STDMETHOD(unbind)(VARIANT_BOOL* pret);
  50. STDMETHOD(enquireLink)(VARIANT_BOOL* pret);
  51. STDMETHOD(init)(BSTR svrip, LONG port);
  52. STDMETHOD(close)(void);
  53. STDMETHOD(get_Connected)(VARIANT_BOOL* pVal);
  54. protected:
  55. static void __stdcall processPacketProc(CPacketBase *pak, LPVOID param);
  56. void processPacket(CPacketBase *pak);
  57. void NotifyClientDeliverSM(CDeliverSM *pak);
  58. protected:
  59. HANDLE m_response_event; //set when a response is got
  60. bool m_last_error; //last command has error
  61. CRITICAL_SECTION m_cs;
  62. };
  63. OBJECT_ENTRY_AUTO(__uuidof(EsmeReceiverCom), CEsmeReceiverCom)