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

#ifndef LIBDEVCPP_JESOCKCOMMPROTOCOL_H
#define LIBDEVCPP_JESOCKCOMMPROTOCOL_H

#include <mgbus/QCommonProtocol.h>

namespace jedge {

    static const char* mf_protocol_key_beat_ = "beat";
    static const char* mf_protocol_key_auth_ = "auth";
    static const char* mf_protocol_key_quit_ = "quit";
    static const char* mf_protocol_key_group_ = "group";
    static const char* mf_protocol_key_net_ = "net";
    static const char* mf_protocol_key_client_name_ = "payload.name";

    //处理Mgbus的基础通信消息，采用默认的JedgeCommonProtocol
    class JE_API JECommSockProtocol :
            public QCommonProtocol {
    public:
        //初始化协议表
        void initProtocol() override {
            qlibc::QData d;d.putObjFmtString(JEDGE_MGBUS_CMD_KEY, jedge_mgbus_cmd_heart_beat_);
            addMessage(mf_protocol_key_beat_, d);
            d.putObjFmtString(JEDGE_MGBUS_CMD_KEY, jedge_mgbus_cmd_regist_);
            addMessage(mf_protocol_key_auth_, d);
            d.putObjFmtString(JEDGE_MGBUS_CMD_KEY, jedge_mgbus_cmd_quit_);
            addMessage(mf_protocol_key_quit_, d);
            d.putObjFmtString(JEDGE_MGBUS_CMD_KEY, jedge_mgbus_cmd_group_);
            addMessage(mf_protocol_key_group_, d);
            d.putObjFmtString(JEDGE_MGBUS_CMD_KEY, jedge_mgbus_cmd_net_);
            addMessage(mf_protocol_key_net_, d);
            QCommonProtocol::initProtocol();
        }
    };

}

#endif //LIBDEVCPP_JESOCKCOMMPROTOCOL_H
