39 lines
714 B
C
39 lines
714 B
C
|
#pragma once
|
|||
|
#include "zmq.hpp"
|
|||
|
#include <string>
|
|||
|
#include <thread>
|
|||
|
|
|||
|
typedef void (*ParamUpdate)(std::string& msg);
|
|||
|
typedef void (*AlarmHandle)(std::string& msg);
|
|||
|
|
|||
|
class ZeroMq {
|
|||
|
public:
|
|||
|
ZeroMq();
|
|||
|
~ZeroMq();
|
|||
|
|
|||
|
void Resque();
|
|||
|
void Publish();
|
|||
|
void Subscribe();
|
|||
|
|
|||
|
void SetCallBack(ParamUpdate pU, AlarmHandle aH) {
|
|||
|
m_paramUpdate = pU;
|
|||
|
m_alarmHandle = aH;
|
|||
|
}
|
|||
|
|
|||
|
private:
|
|||
|
std::string m_localIp; //本地IP
|
|||
|
std::string m_serverIp; //服务端IP
|
|||
|
|
|||
|
int m_publishPort; //发布端口
|
|||
|
int m_pushPullPort; //推拉端口
|
|||
|
|
|||
|
std::thread m_subThread; //订阅线程
|
|||
|
std::thread m_pushThread; //推线程
|
|||
|
|
|||
|
bool m_subQuit;
|
|||
|
bool m_pushQuit;
|
|||
|
|
|||
|
ParamUpdate m_paramUpdate;
|
|||
|
AlarmHandle m_alarmHandle;
|
|||
|
|
|||
|
};
|