mirror of https://github.com/nostar/urfd.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
523 B
31 lines
523 B
#pragma once
|
|
|
|
#include <string>
|
|
#include <mutex>
|
|
#include <nlohmann/json.hpp>
|
|
#include <map>
|
|
#include <nng/nng.h>
|
|
#include <nng/protocol/pubsub0/pub.h>
|
|
|
|
class CNNGPublisher
|
|
{
|
|
public:
|
|
CNNGPublisher();
|
|
~CNNGPublisher();
|
|
|
|
bool Start(const std::string &addr);
|
|
void Stop();
|
|
|
|
void Publish(const nlohmann::json &event);
|
|
|
|
std::string GetAndClearStats();
|
|
|
|
private:
|
|
nng_socket m_sock;
|
|
std::mutex m_mutex;
|
|
bool m_started;
|
|
|
|
// Event counters
|
|
std::map<std::string, int> m_EventCounts;
|
|
};
|