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

手机短信编程

开发平台:

Visual C++

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