lichao
2021-03-29 6aa7e4c37a70709e7348bd16407c5983a563ed76
src/msg.cpp
@@ -37,7 +37,6 @@
    assert(data && size);
    BHMsg msg(InitMsg(kMsgTypeRequest));
    msg.set_body(data, size);
    BHAddress addr;
    msg.add_route()->set_mq_id(&src_id, sizeof(src_id));
    return msg;
}
@@ -50,10 +49,11 @@
    return msg;
}
BHMsg MakeSubUnsub(const std::vector<std::string> &topics, const MsgType sub_unsub)
BHMsg MakeSubUnsub(const MQId &client, const std::vector<std::string> &topics, const MsgType sub_unsub)
{
    assert(sub_unsub == kMsgTypeSubscribe || sub_unsub == kMsgTypeUnsubscribe);
    BHMsg msg(InitMsg(sub_unsub));
    msg.add_route()->set_mq_id(&client, sizeof(client));
    DataSub subs;
    for (auto &t : topics) {
        subs.add_topics(t);
@@ -62,8 +62,8 @@
    return msg;
}
BHMsg MakeSub(const std::vector<std::string> &topics) { return MakeSubUnsub(topics, kMsgTypeSubscribe); }
BHMsg MakeUnsub(const std::vector<std::string> &topics) { return MakeSubUnsub(topics, kMsgTypeUnsubscribe); }
BHMsg MakeSub(const MQId &client, const std::vector<std::string> &topics) { return MakeSubUnsub(client, topics, kMsgTypeSubscribe); }
BHMsg MakeUnsub(const MQId &client, const std::vector<std::string> &topics) { return MakeSubUnsub(client, topics, kMsgTypeUnsubscribe); }
BHMsg MakePub(const std::string &topic, const void *data, const size_t size)
{