//
// Created by zx on 2019/11/25.
//

#ifndef MEASURETOPICSERVER_H
#define MEASURETOPICSERVER_H

#include <nnxx/message.h>
#include <nnxx/message_control.h>
#include <nnxx/socket.h>
#include <nnxx/pubsub.h>
#include <nnxx/timeout.h>
#include <nnxx/error.h>
#include <string>
#include <iostream>
#include <mutex>

#define CONNECTSTRING "tcp://127.0.0.1:10080"

class MeasureTopicPublisher
{
public:
    static MeasureTopicPublisher* GetInstance();
    bool Publish(std::string data);
private:
    MeasureTopicPublisher(std::string connectStr);

private:
    struct timeval         m_last_time;
    nnxx::socket m_sock{nnxx::SP, nnxx::PUB};

    std::mutex  m_lock;
    static MeasureTopicPublisher* g_publisher;
};


#endif //MEASURETOPICSERVER_H
