• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 COMMUNICATIONNETSTACK_CONSTANT_H
17 #define COMMUNICATIONNETSTACK_CONSTANT_H
18 
19 #include <map>
20 #include <string>
21 
22 namespace OHOS::NetStack {
23 enum {
24     FUNCTION_PARAM_ZERO = 0,
25     FUNCTION_PARAM_ONE = 1,
26     FUNCTION_PARAM_TWO = 2,
27     FUNCTION_PARAM_THREE = 3,
28 };
29 
30 enum WebsocketErrorCode {
31     WEBSOCKET_CONNECT_FAILED = -1,
32     WEBSOCKET_ERROR_CODE_BASE = 2302000,
33     WEBSOCKET_UNKNOWN_OTHER_ERROR = 2302999
34 };
35 
36 static const std::map<int32_t, std::string> WEBSOCKET_ERR_MAP = {
37     {WEBSOCKET_CONNECT_FAILED, "Websocket connect failed"},
38     {WEBSOCKET_UNKNOWN_OTHER_ERROR, "Websocket Unknown Other Error"}
39 };
40 
41 enum {
42     CLOSE_REASON_NORMAL_CLOSE [[maybe_unused]] = 1000,
43     CLOSE_REASON_SERVER_CLOSED [[maybe_unused]] = 1001,
44     CLOSE_REASON_PROTOCOL_ERROR [[maybe_unused]] = 1002,
45     CLOSE_REASON_UNSUPPORT_DATA_TYPE [[maybe_unused]] = 1003,
46     CLOSE_REASON_RESERVED1 [[maybe_unused]],
47     CLOSE_REASON_RESERVED2 [[maybe_unused]],
48     CLOSE_REASON_RESERVED3 [[maybe_unused]],
49     CLOSE_REASON_RESERVED4 [[maybe_unused]],
50     CLOSE_REASON_RESERVED5 [[maybe_unused]],
51     CLOSE_REASON_RESERVED6 [[maybe_unused]],
52     CLOSE_REASON_RESERVED7 [[maybe_unused]],
53     CLOSE_REASON_RESERVED8 [[maybe_unused]],
54     CLOSE_REASON_RESERVED9 [[maybe_unused]],
55     CLOSE_REASON_RESERVED10 [[maybe_unused]],
56     CLOSE_REASON_RESERVED11 [[maybe_unused]],
57     CLOSE_REASON_RESERVED12 [[maybe_unused]],
58 };
59 
60 class ContextKey final {
61 public:
62     static const char *HEADER;
63 
64     static const char *CODE;
65 
66     static const char *REASON;
67 };
68 
69 class EventName final {
70 public:
71     static const char *EVENT_OPEN;
72 
73     static const char *EVENT_MESSAGE;
74 
75     static const char *EVENT_CLOSE;
76 
77     static const char *EVENT_ERROR;
78 };
79 } // namespace OHOS::NetStack
80 #endif /* COMMUNICATIONNETSTACK_CONSTANT_H */
81