C++客户端开发接口库 V5.1.8.15
连接信创集成中间件服务程序的二次开发接口
载入中...
搜索中...
未找到
MidLinkBase.h
1#pragma once
2#include "MDWLogger.h"
3#include "MDWPack.h"
4#include <list>
5#include "mdwclient_global.h"
6#ifdef QT_CORE_LIB
7#include <QtCore>
8#endif
9
13namespace mdwc
14{
15 class CMidLinkDLL;
16 class CMidLinkServer;
17 class CMidLinkComm;
18 class CRDMSLogHelper;
19 class CMidLinkMessage;
20 struct CommObject;
21
23 class MDWC_COMPLILE MidLinkBase
24 {
25 private:
27 int m_iTxmmKey;
29 bool m_bInited;
31 bool m_bLoadDllRegister;
33 std::string m_sMachineID;
35 std::list<CommObject> m_lstMidLinkCommPools;
37 int m_iAutoRecycleCommObjectWaitTimes;
39 int m_iMaxConnectCount = 1;
41 std::string m_sProductName;
43 std::string m_sProductVersion;
45 MidCharSet m_LocalCharSet;
47 std::mutex m_VisitMutex;
49 static std::string m_sLastErrorMsg;
51 static std::mutex m_mutexLastErrorMsg;
52 private:
53 // 禁止拷贝构造函数
54 MidLinkBase(const MidLinkBase&) = delete;
55 // 禁止拷贝赋值运算符
56 MidLinkBase& operator=(const MidLinkBase&) = delete;
57
59 static void SetLastErrorMsg(const std::string& sErrorMsg);
60
69 void SetInitParameter(const std::string& sProductName, const std::string& sVersion, MidCharSet eDefaultChatSet,
70 int iAutoRecycleCommObjectWaitTimes);
71 public:
73 std::unique_ptr<CMidLinkDLL> MidLinkDLL;
75 std::unique_ptr<CMDWLogger> MDWLogger;
77 std::unique_ptr<CRDMSLogHelper> RDMSLogHelper;
79 std::unique_ptr<CMidLinkMessage> MidLinkMessage;
81 std::unique_ptr<CMidLinkServer> MidLinkServer;
82 public:
93 static mdwc::MidLinkBase* Initialize(const std::string& sProductName, const std::string& sVersion, const std::string& sWorkDirectory = "", MidCharSet eDefaultChatSet = MidCharSet::AUTO,
94 int iAutoRecycleCommObjectWaitTimes = 120);
95
96#ifdef QT_CORE_LIB
107 static mdwc::MidLinkBase* Initialize(const QString& usProductName, const QString& usVersion,
108 const QString& usWorkDirectory = QString(""), MidCharSet eDefaultChatSet = MidCharSet::AUTO,
109 int iAutoRecycleCommObjectWaitTimes = 120)
110 {
111 return Initialize(usProductName.toStdString(), usVersion.toStdString(), usWorkDirectory.toStdString(), eDefaultChatSet, iAutoRecycleCommObjectWaitTimes);
112 }
113#endif
114
116 static void UnInitialize();
117
119 std::string GetMachineID() { return m_sMachineID; }
120
126 inline bool Inited() { return m_bInited; }
135 int GetConnectStatus(std::string& sConnectStatus);
142 bool GetConnectServerInfo(MIDServerInfo& sInfo);
143 public:
145 MidLinkBase();
147 ~MidLinkBase();
149 int GetTxmmKey() { return m_iTxmmKey; }
155 static std::string GetLastErrorMessage() {
156 // 加锁读取静态错误信息,返回副本,避免与写入线程数据竞争
157 std::lock_guard<std::mutex> lock(m_mutexLastErrorMsg);
158 return m_sLastErrorMsg;
159 }
160
170 bool OpenMidLinkComm(const std::string& sIPAdress, int iCommPort, int iTimeOut, const std::string& sTokenID = "");
178 bool OpenMidLinkComm(const std::string& sConfigFile = "", bool bConnectedServer = true);
179
180#ifdef QT_CORE_LIB
188 bool OpenMidLinkComm(const QString& usConfigFile = QString(""), bool bConnectedServer = true)
189 {
190 return OpenMidLinkComm(usConfigFile.toStdString(), bConnectedServer);
191 }
192#endif
193
200 bool SetCommCharSet(MidCharSet eCharSetID);
205 void RecycleMidLinkComm(int iFreeTime);
206
212 std::vector<std::string> GetMidLinkCommPoolStatus();
213
219 CMidLinkComm* GetMidLinkComm(const std::string& sOperate);
220
230 CMidLinkComm* GetMidLinkComm(const std::string& sOperate, const std::string& sIPAdress,
231 short iCommPort, int iTimeOut = 30, const std::string& sTokenID = "");
232
239 void ReleaseMidLinkComm(mdwc::CMidLinkComm* comm, bool bRemove = false);
240
245 void CloseMidLinkComm(bool bReleaseComm);
246
257 int RegisterUser(std::string UserCode, std::string UserName);
258
263 int UnRegisterUser();
264
275 int RegisterRDMS(int iConnectNo, std::string sClientID, unsigned short wPort, bool bLogOut, bool bPMPMode);
276
284 bool SendNetMessage(mdwc::MSG_TYPE eMsgType, std::string sMsgContext);
285
294 int SendTextMessage(std::string sReceives, std::string sMsgContext, std::string sSended);
295
301 std::vector<mdwc::Logon_UserInfo> GetClientLoginInfo();
302
309 int GetShowedMessage(mdwc::NET_MESSAGE& retmsg);
310
316 std::string GetLocalMACAddres();
317
324 bool ReceiveMulticastFile(bool bEnabled, const std::string& sFileType = "*");
325
333 std::string Encrypt10Char(const std::string& sSou, int iPinKey);
334
342 std::string Encrypt(const std::string& sSou, int iPinKey);
343
351 std::string Decrypt10Char(const std::string& sSou, int iPinKey);
352
360 std::string Decrypt(const std::string& sSou, int iPinKey);
361 };
362}
363
365extern mdwc::MidLinkBase* mc;
366
定义 RDMSLogHelper.h:32
定义 AutoUpdateHelper.h:8
MidCharSet
定义 MDWPack.h:86
@ AUTO
定义 MDWPack.h:88
MSG_TYPE
定义 MDWPack.h:97
定义 CommObject.h:10
定义 MDWPack.h:245
定义 MDWPack.h:185