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

手机短信编程

开发平台:

Visual C++

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