• 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 TLS_MONITOR_H
17 #define TLS_MONITOR_H
18 
19 #include <cstdint>
20 #include <set>
21 #include <string>
22 #include <string_view>
23 
24 #include <napi/native_api.h>
25 
26 #include "event_manager.h"
27 #include "singleton.h"
28 #include "socket_remote_info.h"
29 #include "tls.h"
30 
31 namespace OHOS {
32 namespace NetStack {
33 class Monitor final {
34     DECLARE_DELAYED_SINGLETON(Monitor);
35 
36 public:
37     napi_value On(napi_env env, napi_callback_info info);
38     napi_value Off(napi_env env, napi_callback_info info);
39 
40 public:
41     std::string data_;
42     SocketRemoteInfo remoteInfo_;
43     int32_t errorNumber_ = 0;
44     std::string errorString_;
45 
46 private:
47     EventManager *manager_ = nullptr;
48     std::set<std::string_view> monitors_;
49 };
50 } // namespace NetStack
51 } // namespace OHOS
52 #endif // TLS_CONTEXT_MONITOR_CONTEXT_H
53