• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_MSG_HEAD_H
17 #define OHOS_MSG_HEAD_H
18 
19 #include "nlohmann/json.hpp"
20 
21 namespace OHOS {
22 namespace DistributedHardware {
23 enum DmMsgType : int32_t {
24     MSG_TYPE_UNKNOWN = 0,
25     MSG_TYPE_REQ_AUTH = 100,
26     MSG_TYPE_INVITE_AUTH_INFO = 102,
27     MSG_TYPE_RESP_AUTH = 200,
28     MSG_TYPE_JOIN_AUTH_INFO = 201,
29     MSG_TYPE_CHANNEL_CLOSED = 300,
30     MSG_TYPE_SYNC_GROUP = 400,
31     MSG_TYPE_AUTH_BY_PIN = 500,
32 };
33 
34 class MsgHead {
35 public:
MsgHead()36     MsgHead(): mMsgType_(0), mItfVer_("") {};
MsgHead(int32_t msg)37     MsgHead(int32_t msg): mMsgType_(msg), mItfVer_("") {};
38     ~MsgHead() = default;
39     void Encode(nlohmann::json &json);
40     static std::shared_ptr<MsgHead> Decode(nlohmann::json &json);
41     int32_t GetMsgType();
42 private:
43     int32_t mMsgType_;
44     std::string mItfVer_;
45 };
46 }
47 }
48 #endif