MemPushBLOB.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #pragma once
  2. #include "BUSClient.MainEntry.hpp"
  3. namespace BUSC = ECOM::ServiceBus::Controller;
  4. #ifndef _ServiceBus_DLL
  5. #define _ServiceBus_API _declspec(dllimport)
  6. #else
  7. #define _ServiceBus_API _declspec(dllexport)
  8. #endif
  9. namespace ECOM
  10. {
  11. namespace ServiceBus
  12. {
  13. namespace Controller
  14. {
  15. class _ServiceBus_API MessageClient;
  16. };
  17. namespace MemMapExchBLOB
  18. {
  19. class _ServiceBus_API PushManager
  20. {
  21. public:
  22. static void SetLogFileName (const char * FileName);
  23. static void Prepare ();
  24. static void Quit ();
  25. // 设置缺省的超时, 单位: 毫秒
  26. static void SetDefTimeOut (int msTimeOut);
  27. };
  28. class _ServiceBus_API PushBLOB_Base
  29. {
  30. protected:
  31. PushBLOB_Base (PCTSTR TargetID);
  32. public:
  33. virtual ~PushBLOB_Base ();
  34. void SetTransactionID (DWORD ID);
  35. // 立即发送
  36. bool Push (const BlockBuffer & BLOB, int msTimeOut = gDefMSTimeOut);
  37. // 立即发送, 带附加参数
  38. bool Push (const BlockBuffer & BLOB, DString UserInfo, int msTimeOut = gDefMSTimeOut);
  39. // 通知接收方, 交易开始
  40. void BeginTransaction ();
  41. // 通知接收方, 交易结束, 立即发送
  42. void EndTransactionNow ();
  43. protected:
  44. DWORD m_TransactionID;
  45. bool m_bTargetOnline;
  46. DString m_TargetID;
  47. Controller::MessageClient * m_Client;
  48. protected:
  49. friend PushManager;
  50. static int gDefMSTimeOut;
  51. };
  52. class _ServiceBus_API PushBLOB : public PushBLOB_Base
  53. {
  54. public:
  55. PushBLOB (PCTSTR SourceID, PCTSTR TargetID);
  56. PushBLOB (const PushBLOB &) = delete;
  57. PushBLOB (PushBLOB &&) = delete;
  58. PushBLOB & operator = (const PushBLOB &) = delete;
  59. public:
  60. // 后台发送
  61. bool Post (const BlockBuffer & BLOB);
  62. // 通知接收方, 交易结束
  63. void EndTransaction ();
  64. friend class PushFileServer;
  65. };
  66. class _ServiceBus_API FixedPushBLOB : public PushBLOB_Base
  67. {
  68. public:
  69. FixedPushBLOB (PCTSTR SourceID, PCTSTR TargetID, int Port = BUSC::LegacySendPort);
  70. FixedPushBLOB (const FixedPushBLOB &) = delete;
  71. FixedPushBLOB (FixedPushBLOB &&) = delete;
  72. FixedPushBLOB & operator = (const FixedPushBLOB &) = delete;
  73. public:
  74. // 后台发送
  75. bool Post (const BlockBuffer & BLOB);
  76. // 通知接收方, 交易结束
  77. void EndTransaction ();
  78. private:
  79. int m_Port;
  80. };
  81. }
  82. }
  83. };