1 /* 2 * Copyright (C) 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 NETMANAGER_EXT_MDNS_MODULE_H 17 #define NETMANAGER_EXT_MDNS_MODULE_H 18 19 #include <cstdint> 20 #include <string_view> 21 22 #include "module_template.h" 23 #include "napi/native_api.h" 24 #include "napi/native_common.h" 25 #include "napi_utils.h" 26 27 #include "constant.h" 28 #include "mdns_addlocalservice_context.h" 29 #include "mdns_async_work.h" 30 #include "mdns_removelocalservice_context.h" 31 #include "mdns_startsearching_context.h" 32 #include "netmgr_ext_log_wrapper.h" 33 34 namespace OHOS { 35 namespace NetManagerStandard { 36 class MDnsModule final { 37 public: 38 static constexpr const char *FUNCTION_CREATE_DISCOVERY = "createDiscoveryService"; 39 static constexpr const char *FUNCTION_ADDLOCALSERVICE = "addLocalService"; 40 static constexpr const char *FUNCTION_REMOVELOCALSERVICE = "removeLocalService"; 41 static constexpr const char *FUNCTION_RESOLVELOCALSERVICE = "resolveLocalService"; 42 static constexpr const char *FUNCTION_DISCOVERY_SERVICE = "discoveryService"; 43 44 class DiscoveryServiceInterface final { 45 public: 46 static constexpr const char *FUNCTION_ON = "on"; 47 static constexpr const char *FUNCTION_OFF = "off"; 48 static constexpr const char *FUNCTION_STARTSEARCHINGMDNS = "startSearchingMDNS"; 49 static constexpr const char *FUNCTION_STOPSEARCHINGMDNS = "stopSearchingMDNS"; 50 51 static napi_value On(napi_env env, napi_callback_info info); 52 static napi_value Off(napi_env env, napi_callback_info info); 53 static napi_value StartSearchingMDNS(napi_env env, napi_callback_info info); 54 static napi_value StopSearchingMDNS(napi_env env, napi_callback_info info); 55 }; 56 57 static napi_value InitMDnsModule(napi_env env, napi_value exports); 58 static napi_value CreateDiscoveryService(napi_env env, napi_callback_info info); 59 static napi_value AddLocalService(napi_env env, napi_callback_info info); 60 static napi_value RemoveLocalService(napi_env env, napi_callback_info info); 61 static napi_value ResolveLocalService(napi_env env, napi_callback_info info); 62 }; 63 } // namespace NetManagerStandard 64 } // namespace OHOS 65 #endif /* NETMANAGER_EXT_MDNS_MODULE_H */