2,新增“Apps”; 3,新增“Common”; 4,新增“FileList”; 5,新增“MediaX”; 6,新增“OpenSource”; 7,新增“Samples”; 8,新增“SoftwareBusinessLines”.
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
#ifndef _GdZeroMQ_H_
|
|
#define _GdZeroMQ_H_
|
|
|
|
#include <QDebug>
|
|
|
|
#include <thread>
|
|
#include <chrono>
|
|
using namespace std;
|
|
|
|
#include "zmq.h"
|
|
|
|
typedef void (*pCallBack_RecvData)(QByteArray szTopic,QByteArray szAddr,QByteArray szData, void* pOwner);
|
|
|
|
class GdZeroMQ
|
|
{
|
|
public:
|
|
GdZeroMQ();
|
|
~GdZeroMQ();
|
|
|
|
bool Init(int nPort_Publisher, QVector<int> nPorts_Subscriber, const char* lpszPublisherName, pCallBack_RecvData pCB_RecvData, void* pOwner);
|
|
void SendData(char* lpszObjName, QByteArray szData);
|
|
|
|
private:
|
|
void Uninit();
|
|
|
|
void CreatePublisher(int nPort_Publisher);
|
|
void CreateSubscriber(QVector<int> nPorts_Subscriber);
|
|
void AddTopic(const char* lpszTopicName);
|
|
|
|
private:
|
|
typedef void (GdZeroMQ::*ThreadRunFunPtr)();
|
|
static void ThreadEntry(ThreadRunFunPtr pRunFun, void* pOwner);
|
|
void ThreadFun_RecvData();
|
|
|
|
bool StartThread();
|
|
void StopThread();
|
|
|
|
private:
|
|
bool m_bInit;
|
|
void* m_pContext;
|
|
void* m_pPublisher; // 发布
|
|
void* m_pSubscriber; // 订阅
|
|
char* m_lpszSelfName;
|
|
|
|
bool m_bThreadRunning_RecvData;
|
|
std::thread* m_ptrThread_RecvData;
|
|
|
|
pCallBack_RecvData m_pCallBack_RecvData;
|
|
void* m_pOwner;
|
|
};
|
|
|
|
#endif // _GdZeroMQ_H_
|