-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzerorunner.h
48 lines (37 loc) · 1.03 KB
/
zerorunner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include "gen/stdfunc.h"
#include "protos/protos.pb.h"
#include "zeropublisher.h"
#include "zerosubscriber.h"
#include <QMutex>
#include <QObject>
#include <zmq.hpp>
constexpr uint32_t timeout = 300000;
class ZeroRunner : public QObject
{
Q_OBJECT
public:
ZeroRunner(const QString &type, QObject *parent = nullptr);
public slots:
void runServer(int port);
void stopServer();
void publishHealthQueryCallback();
void publishNtpStatus(bool);
void publishBlock(const DataTypes::BlockStruct &blk);
void publishTime(const timespec &time);
signals:
void timeRequest();
void healthReceived(uint32_t);
void timeReceived(timespec);
private:
void proxy(zmq::socket_t &front, zmq::socket_t &sub, zmq::socket_t &pub);
void polling();
QMutex _mutex;
zmq::context_t ctx_;
zmq::socket_t frontend_;
zmq::socket_t backendSub_;
zmq::socket_t backendPub_;
// UniquePointer<DataTypesProxy> proxyBS, proxyTS;
ZeroSubscriber *m_subscriber;
ZeroPublisher *m_publisher;
};