1 /* 2 * Copyright (c) 2022-2023 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 <napi/native_api.h> 21 #include <queue> 22 #include <set> 23 #include <string> 24 #include <string_view> 25 26 #include "event_manager.h" 27 #include "singleton.h" 28 #include "socket_remote_info.h" 29 #include "tls.h" 30 #include "tls_socket.h" 31 32 namespace OHOS { 33 namespace NetStack { 34 namespace TlsSocket { 35 36 class Monitor final { 37 DECLARE_DELAYED_SINGLETON(Monitor); 38 39 public: 40 napi_value On(napi_env env, napi_callback_info info); 41 napi_value Off(napi_env env, napi_callback_info info); 42 class MessageRecvParma { 43 public: 44 std::string data_; 45 Socket::SocketRemoteInfo remoteInfo_; 46 }; 47 class ErrorRecvParma { 48 public: 49 int32_t errorNumber_ = 0; 50 std::string errorString_; 51 }; 52 53 private: 54 void ParserEventForOn(const std::string event, TlsSocket::TLSSocket *tlsSocket, EventManager *manager); 55 void ParserEventForOff(const std::string event, TlsSocket::TLSSocket *tlsSocket); 56 }; 57 } // namespace TlsSocket 58 } // namespace NetStack 59 } // namespace OHOS 60 #endif // TLS_CONTEXT_MONITOR_CONTEXT_H 61