//
// Created by Ht on 2020/5/8.
//

#ifndef TESTBIN_MUFISDATACHANNEL_H
#define TESTBIN_MUFISDATACHANNEL_H

#include <utility>

#include "ChannelOperator.h"

namespace jedge {

    class JE_API MgDataChannel :
            public qlibc::QSelfRefObject {
    protected:
        ChannelOperator& operator_;
        httplib::RThreadPool pool_;
        std::string      channel_name_;

    public:
        explicit MgDataChannel(ChannelOperator& opr, std::string name = "") : operator_(opr), pool_(opr.threadPoolRef()), channel_name_(std::move(name)){}

        virtual ~MgDataChannel() = default;

        virtual bool postRawMessage(qlibc::QData& message) = 0;

        virtual const std::string& name(){
            return channel_name_;
        }

        virtual void updateName(const std::string &newname){
            channel_name_ = newname;
        }

        inline const std::string &objId() override {
            return channel_name_;
        }
    };

}
#endif //TESTBIN_MUFISDATACHANNEL_H
