@react-native-ohos/react-native-tcp-socket 6.2.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.OpenSource +11 -0
- package/README.md +13 -0
- package/harmony/tcp_socket/Index.ets +9 -0
- package/harmony/tcp_socket/build-profile.json5 +31 -0
- package/harmony/tcp_socket/consumer-rules.txt +0 -0
- package/harmony/tcp_socket/hvigorfile.ts +6 -0
- package/harmony/tcp_socket/obfuscation-rules.txt +23 -0
- package/harmony/tcp_socket/oh-package.json5 +11 -0
- package/harmony/tcp_socket/src/main/cpp/CMakeLists.txt +10 -0
- package/harmony/tcp_socket/src/main/cpp/TcpSocketPackage.h +26 -0
- package/harmony/tcp_socket/src/main/cpp/generated/RNOH/generated/BaseReactNativeTcpSocketPackage.h +65 -0
- package/harmony/tcp_socket/src/main/cpp/generated/RNOH/generated/turbo_modules/TcpSocketModule.cpp +28 -0
- package/harmony/tcp_socket/src/main/cpp/generated/RNOH/generated/turbo_modules/TcpSocketModule.h +16 -0
- package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/ComponentDescriptors.h +22 -0
- package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/EventEmitters.cpp +18 -0
- package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/EventEmitters.h +19 -0
- package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/Props.cpp +21 -0
- package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/Props.h +20 -0
- package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/ShadowNodes.cpp +19 -0
- package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/ShadowNodes.h +25 -0
- package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/States.cpp +18 -0
- package/harmony/tcp_socket/src/main/cpp/generated/react/renderer/components/react_native_tcp_socket/States.h +23 -0
- package/harmony/tcp_socket/src/main/ets/Logger.ts +46 -0
- package/harmony/tcp_socket/src/main/ets/TcpEventListener.ts +121 -0
- package/harmony/tcp_socket/src/main/ets/TcpSocket.ts +17 -0
- package/harmony/tcp_socket/src/main/ets/TcpSocketClient.ts +444 -0
- package/harmony/tcp_socket/src/main/ets/TcpSocketPackage.ets +27 -0
- package/harmony/tcp_socket/src/main/ets/TcpSocketServer.ts +151 -0
- package/harmony/tcp_socket/src/main/ets/TcpSocketTurboModule.ts +224 -0
- package/harmony/tcp_socket/src/main/ets/generated/components/ts.ts +5 -0
- package/harmony/tcp_socket/src/main/ets/generated/index.ets +5 -0
- package/harmony/tcp_socket/src/main/ets/generated/ts.ts +6 -0
- package/harmony/tcp_socket/src/main/ets/generated/turboModules/TcpSocketModule.ts +38 -0
- package/harmony/tcp_socket/src/main/ets/generated/turboModules/ts.ts +5 -0
- package/harmony/tcp_socket/src/main/module.json5 +11 -0
- package/harmony/tcp_socket/src/main/resources/base/element/string.json +8 -0
- package/harmony/tcp_socket/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/tcp_socket/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/tcp_socket/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/harmony/tcp_socket/src/ohosTest/ets/test/List.test.ets +5 -0
- package/harmony/tcp_socket/src/ohosTest/module.json5 +13 -0
- package/harmony/tcp_socket/src/test/List.test.ets +5 -0
- package/harmony/tcp_socket/src/test/LocalUnit.test.ets +33 -0
- package/harmony/tcp_socket/ts.ets +7 -0
- package/harmony/tcp_socket.har +0 -0
- package/lib/types/Globals.d.ts +2 -0
- package/lib/types/Server.d.ts +114 -0
- package/lib/types/Socket.d.ts +272 -0
- package/lib/types/TLSServer.d.ts +28 -0
- package/lib/types/TLSSocket.d.ts +50 -0
- package/lib/types/index.d.ts +62 -0
- package/package.json +90 -0
- package/src/Globals.js +12 -0
- package/src/Server.js +185 -0
- package/src/Socket.js +513 -0
- package/src/TLSServer.js +70 -0
- package/src/TLSSocket.js +93 -0
- package/src/TcpSocketModule.ts +40 -0
- package/src/index.js +131 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Rapsssito
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "react-native-tcp-socket",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File": "https://github.com/Rapsssito/react-native-tcp-socket/blob/master/LICENSE",
|
|
6
|
+
"Version Number": "6.2.0",
|
|
7
|
+
"Owner" : "xiafeng@huawei.com",
|
|
8
|
+
"Upstream URL": "https://github.com/Rapsssito/react-native-tcp-socket",
|
|
9
|
+
"Description": "React Native TCP socket API for HarmonyOS with SSL/TLS support"
|
|
10
|
+
}
|
|
11
|
+
]
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @react-native-ohos/react-native-tcp-socket
|
|
2
|
+
|
|
3
|
+
This project is based on [react-native-tcp-socket](https://github.com/Rapsssito/react-native-tcp-socket)@6.3.0
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
- [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-tcp-socket.md)
|
|
8
|
+
|
|
9
|
+
- [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-tcp-socket.md)
|
|
10
|
+
|
|
11
|
+
## License
|
|
12
|
+
|
|
13
|
+
This library is licensed under [The MIT License (MIT)](https://github.com/Rapsssito/react-native-tcp-socket/blob/master/LICENSE)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
import { TcpSocketPackage } from './src/main/ets/TcpSocketPackage';
|
|
7
|
+
export * from './ts'
|
|
8
|
+
|
|
9
|
+
export default TcpSocketPackage;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiType": "stageMode",
|
|
3
|
+
"buildOption": {
|
|
4
|
+
},
|
|
5
|
+
"buildOptionSet": [
|
|
6
|
+
{
|
|
7
|
+
"name": "release",
|
|
8
|
+
"arkOptions": {
|
|
9
|
+
"obfuscation": {
|
|
10
|
+
"ruleOptions": {
|
|
11
|
+
"enable": false,
|
|
12
|
+
"files": [
|
|
13
|
+
"./obfuscation-rules.txt"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"consumerFiles": [
|
|
17
|
+
"./consumer-rules.txt"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
"targets": [
|
|
24
|
+
{
|
|
25
|
+
"name": "default"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "ohosTest"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
|
+
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
19
|
+
|
|
20
|
+
-enable-property-obfuscation
|
|
21
|
+
-enable-toplevel-obfuscation
|
|
22
|
+
-enable-filename-obfuscation
|
|
23
|
+
-enable-export-obfuscation
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/react-native-tcp-socket",
|
|
3
|
+
"version": "6.2.1-rc.1",
|
|
4
|
+
"description": "Please describe the basic information.",
|
|
5
|
+
"main": "Index.ets",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@rnoh/react-native-openharmony": "file:../libs/react_native_openharmony-5.0.0.491.har"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# the minimum version of CMake
|
|
2
|
+
cmake_minimum_required(VERSION 3.13)
|
|
3
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
4
|
+
|
|
5
|
+
set(rnoh_tcp_socket_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
|
|
6
|
+
file(GLOB_RECURSE rnoh_tcp_socket_generated_SRC "${rnoh_tcp_socket_generated_dir}/**/*.cpp")
|
|
7
|
+
file(GLOB rnoh_tcp_socket_SRC CONFIGURE_DEPENDS *.cpp)
|
|
8
|
+
add_library(rnoh_tcp_socket SHARED ${rnoh_tcp_socket_SRC} ${rnoh_tcp_socket_generated_SRC})
|
|
9
|
+
target_include_directories(rnoh_tcp_socket PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_tcp_socket_generated_dir})
|
|
10
|
+
target_link_libraries(rnoh_tcp_socket PUBLIC rnoh)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
|
4
|
+
* Licensed under the MIT License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://gitee.com/openharmony-sig/rntpc_react-native-document-picker
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include "generated/RNOH/generated/BaseReactNativeTcpSocketPackage.h"
|
|
20
|
+
|
|
21
|
+
namespace rnoh {
|
|
22
|
+
class TcpSocketPackage : public BaseReactNativeTcpSocketPackage {
|
|
23
|
+
using Super = BaseReactNativeTcpSocketPackage;
|
|
24
|
+
using Super::Super;
|
|
25
|
+
};
|
|
26
|
+
} // namespace rnoh
|
package/harmony/tcp_socket/src/main/cpp/generated/RNOH/generated/BaseReactNativeTcpSocketPackage.h
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "RNOH/Package.h"
|
|
8
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
9
|
+
#include "RNOH/generated/turbo_modules/TcpSocketModule.h"
|
|
10
|
+
|
|
11
|
+
namespace rnoh {
|
|
12
|
+
|
|
13
|
+
class BaseReactNativeTcpSocketPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
14
|
+
public:
|
|
15
|
+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
16
|
+
if (name == "TcpSocketModule") {
|
|
17
|
+
return std::make_shared<TcpSocketModule>(ctx, name);
|
|
18
|
+
}
|
|
19
|
+
return nullptr;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class BaseReactNativeTcpSocketPackageEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
24
|
+
public:
|
|
25
|
+
void handleEvent(Context const &ctx) override {
|
|
26
|
+
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
27
|
+
if (eventEmitter == nullptr) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
std::vector<std::string> supportedEventNames = {
|
|
32
|
+
};
|
|
33
|
+
if (std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
34
|
+
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class BaseReactNativeTcpSocketPackage : public Package {
|
|
41
|
+
public:
|
|
42
|
+
BaseReactNativeTcpSocketPackage(Package::Context ctx) : Package(ctx){};
|
|
43
|
+
|
|
44
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
45
|
+
return std::make_unique<BaseReactNativeTcpSocketPackageTurboModuleFactoryDelegate>();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
49
|
+
return {
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
54
|
+
return {
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
EventEmitRequestHandlers createEventEmitRequestHandlers() override {
|
|
59
|
+
return {
|
|
60
|
+
std::make_shared<BaseReactNativeTcpSocketPackageEventEmitRequestHandler>(),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace rnoh
|
package/harmony/tcp_socket/src/main/cpp/generated/RNOH/generated/turbo_modules/TcpSocketModule.cpp
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#include "TcpSocketModule.h"
|
|
6
|
+
|
|
7
|
+
namespace rnoh {
|
|
8
|
+
using namespace facebook;
|
|
9
|
+
|
|
10
|
+
TcpSocketModule::TcpSocketModule(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
|
|
11
|
+
methodMap_ = {
|
|
12
|
+
ARK_METHOD_METADATA(listen, 2),
|
|
13
|
+
ARK_METHOD_METADATA(close, 1),
|
|
14
|
+
ARK_METHOD_METADATA(destroy, 1),
|
|
15
|
+
ARK_METHOD_METADATA(end, 1),
|
|
16
|
+
ARK_METHOD_METADATA(pause, 1),
|
|
17
|
+
ARK_METHOD_METADATA(resume, 1),
|
|
18
|
+
ARK_METHOD_METADATA(connect, 4),
|
|
19
|
+
ARK_METHOD_METADATA(startTLS, 2),
|
|
20
|
+
ARK_METHOD_METADATA(write, 3),
|
|
21
|
+
ARK_METHOD_METADATA(setNoDelay, 2),
|
|
22
|
+
ARK_METHOD_METADATA(setKeepAlive, 3),
|
|
23
|
+
ARK_ASYNC_METHOD_METADATA(getPeerCertificate, 1),
|
|
24
|
+
ARK_ASYNC_METHOD_METADATA(getCertificate, 1),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
} // namespace rnoh
|
package/harmony/tcp_socket/src/main/cpp/generated/RNOH/generated/turbo_modules/TcpSocketModule.h
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
8
|
+
|
|
9
|
+
namespace rnoh {
|
|
10
|
+
|
|
11
|
+
class JSI_EXPORT TcpSocketModule : public ArkTSTurboModule {
|
|
12
|
+
public:
|
|
13
|
+
TcpSocketModule(const ArkTSTurboModule::Context ctx, const std::string name);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <react/renderer/components/react_native_tcp_socket/ShadowNodes.h>
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
|
|
16
|
+
namespace facebook {
|
|
17
|
+
namespace react {
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
} // namespace react
|
|
22
|
+
} // namespace facebook
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <react/renderer/components/react_native_tcp_socket/EventEmitters.h>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook {
|
|
15
|
+
namespace react {
|
|
16
|
+
|
|
17
|
+
} // namespace react
|
|
18
|
+
} // namespace facebook
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace facebook {
|
|
16
|
+
namespace react {
|
|
17
|
+
|
|
18
|
+
} // namespace react
|
|
19
|
+
} // namespace facebook
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <react/renderer/components/react_native_tcp_socket/Props.h>
|
|
12
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
13
|
+
#include <react/renderer/core/propsConversions.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook {
|
|
16
|
+
namespace react {
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
} // namespace react
|
|
21
|
+
} // namespace facebook
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook {
|
|
15
|
+
namespace react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace react
|
|
20
|
+
} // namespace facebook
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <react/renderer/components/react_native_tcp_socket/ShadowNodes.h>
|
|
12
|
+
|
|
13
|
+
namespace facebook {
|
|
14
|
+
namespace react {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
} // namespace react
|
|
19
|
+
} // namespace facebook
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <react/renderer/components/react_native_tcp_socket/EventEmitters.h>
|
|
14
|
+
#include <react/renderer/components/react_native_tcp_socket/Props.h>
|
|
15
|
+
#include <react/renderer/components/react_native_tcp_socket/States.h>
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <jsi/jsi.h>
|
|
18
|
+
|
|
19
|
+
namespace facebook {
|
|
20
|
+
namespace react {
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
} // namespace react
|
|
25
|
+
} // namespace facebook
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateStateCpp.js
|
|
9
|
+
*/
|
|
10
|
+
#include <react/renderer/components/react_native_tcp_socket/States.h>
|
|
11
|
+
|
|
12
|
+
namespace facebook {
|
|
13
|
+
namespace react {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
} // namespace react
|
|
18
|
+
} // namespace facebook
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateStateH.js
|
|
8
|
+
*/
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#ifdef ANDROID
|
|
12
|
+
#include <folly/dynamic.h>
|
|
13
|
+
#include <react/renderer/mapbuffer/MapBuffer.h>
|
|
14
|
+
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
namespace facebook {
|
|
18
|
+
namespace react {
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
} // namespace react
|
|
23
|
+
} // namespace facebook
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import hilog from '@ohos.hilog';
|
|
8
|
+
|
|
9
|
+
class Logger {
|
|
10
|
+
private domain: number;
|
|
11
|
+
private prefix: string;
|
|
12
|
+
private format: string = '%{public}s, %{public}s';
|
|
13
|
+
private isDebug: boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* constructor.
|
|
17
|
+
*
|
|
18
|
+
* @param Prefix Identifies the log tag.
|
|
19
|
+
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
|
|
20
|
+
*/
|
|
21
|
+
constructor(prefix: string = 'RNCToolbarAndroid', domain: number = 0xFF00, isDebug = false) {
|
|
22
|
+
this.prefix = prefix;
|
|
23
|
+
this.domain = domain;
|
|
24
|
+
this.isDebug = isDebug;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
debug(...args: string[]): void {
|
|
28
|
+
if (this.isDebug) {
|
|
29
|
+
hilog.debug(this.domain, this.prefix, this.format, args);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
info(...args: string[]): void {
|
|
34
|
+
hilog.info(this.domain, this.prefix, this.format, args);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
warn(...args: string[]): void {
|
|
38
|
+
hilog.warn(this.domain, this.prefix, this.format, args);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
error(...args: string[]): void {
|
|
42
|
+
hilog.error(this.domain, this.prefix, this.format, args);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default new Logger('RNTextSizeTurboModule', 0xFF00, false)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
import { RNInstance, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
7
|
+
import { TcpSocketClient } from './TcpSocketClient'
|
|
8
|
+
import { TcpSocketServer } from './TcpSocketServer'
|
|
9
|
+
import { socket } from '@kit.NetworkKit';
|
|
10
|
+
|
|
11
|
+
export class TcpEventListener {
|
|
12
|
+
private rnInstance?: RNInstance;
|
|
13
|
+
|
|
14
|
+
constructor(ctx: TurboModuleContext) {
|
|
15
|
+
this.rnInstance = ctx.rnInstance;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async onConnection(serverId: number, clientId: number, connection: socket.TCPSocketConnection) {
|
|
19
|
+
let localAddress = await connection?.getLocalAddress() as socket.NetAddress;
|
|
20
|
+
let remoteAddress = await connection?.getRemoteAddress() as socket.NetAddress;
|
|
21
|
+
let localFamily = remoteAddress.family === 2 ? "IPv6" : "IPv4"
|
|
22
|
+
this.sendEvent("connection", {
|
|
23
|
+
"id": serverId,
|
|
24
|
+
"info": {
|
|
25
|
+
"id": clientId,
|
|
26
|
+
"connection": {
|
|
27
|
+
"localAddress": localAddress.address,
|
|
28
|
+
"localPort": localAddress.port,
|
|
29
|
+
"remoteAddress": remoteAddress.address,
|
|
30
|
+
"remotePort": remoteAddress.port,
|
|
31
|
+
"remoteFamily": localFamily
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async onSecureConnection(serverId: number, clientId: number, connection: socket.TLSSocketConnection) {
|
|
38
|
+
let localAddress = await connection?.getLocalAddress() as socket.NetAddress;
|
|
39
|
+
let remoteAddress = await connection?.getRemoteAddress() as socket.NetAddress;
|
|
40
|
+
let remoteFamily = remoteAddress.family === 2 ? "IPv6" : "IPv4"
|
|
41
|
+
this.sendEvent("secureConnection", {
|
|
42
|
+
"id": serverId,
|
|
43
|
+
"info": {
|
|
44
|
+
"id": clientId,
|
|
45
|
+
"connection": {
|
|
46
|
+
"localAddress": localAddress.address,
|
|
47
|
+
"localPort": localAddress.port,
|
|
48
|
+
"remoteAddress": remoteAddress.address,
|
|
49
|
+
"remotePort": remoteAddress.port,
|
|
50
|
+
"remoteFamily": remoteFamily
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
async onConnect(cid: number, client: TcpSocketClient) {
|
|
58
|
+
let tcpSocket: socket.TCPSocket | socket.TLSSocket | socket.TCPSocketConnection | socket.TLSSocketConnection | undefined =
|
|
59
|
+
client.getSocket();
|
|
60
|
+
let localAddress = await tcpSocket?.getLocalAddress() as socket.NetAddress;
|
|
61
|
+
let remoteAddress = await tcpSocket?.getRemoteAddress() as socket.NetAddress;
|
|
62
|
+
let remoteFamily = remoteAddress.family === 2 ? "IPv6" : "IPv4"
|
|
63
|
+
this.sendEvent("connect", {
|
|
64
|
+
"id": cid,
|
|
65
|
+
"connection": {
|
|
66
|
+
"localAddress": localAddress.address,
|
|
67
|
+
"localPort": localAddress.port,
|
|
68
|
+
"remoteAddress": remoteAddress.address,
|
|
69
|
+
"remotePort": remoteAddress.port,
|
|
70
|
+
"remoteFamily": remoteFamily
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async onListen(cId: number, tcpSocketServer: TcpSocketServer) {
|
|
76
|
+
let serverSocket: socket.TCPSocketServer | socket.TLSSocketServer = tcpSocketServer.getServerSocket();
|
|
77
|
+
let address: socket.NetAddress = await serverSocket.getLocalAddress();
|
|
78
|
+
let localFamily = address.family === 2 ? "IPv6" : "IPv4"
|
|
79
|
+
this.sendEvent("listening", {
|
|
80
|
+
"id": cId,
|
|
81
|
+
"connection": {
|
|
82
|
+
"localAddress": address.address,
|
|
83
|
+
"localPort": address.port,
|
|
84
|
+
"localFamily": localFamily
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
onData(id: number,data:string) {
|
|
90
|
+
this.sendEvent("data", {
|
|
91
|
+
"id": id,
|
|
92
|
+
"data": data
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
onWritten(id: number, msgId: number, error: string) {
|
|
97
|
+
this.sendEvent("written", {
|
|
98
|
+
"id": id,
|
|
99
|
+
"msgId": msgId,
|
|
100
|
+
"error": error
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
onClose(id: number, error: string) {
|
|
105
|
+
this.sendEvent("close", {
|
|
106
|
+
"id": id,
|
|
107
|
+
"hadError": error ? true : false
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onError(id: number, error: string): void {
|
|
112
|
+
this.sendEvent("error", {
|
|
113
|
+
"id": id,
|
|
114
|
+
"error": error
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private sendEvent(eventName: string, params: object): void {
|
|
119
|
+
this.rnInstance?.emitDeviceEvent(eventName, params);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export class TcpSocket {
|
|
8
|
+
private id: number;
|
|
9
|
+
|
|
10
|
+
constructor(id: number) {
|
|
11
|
+
this.id = id;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getId(): number {
|
|
15
|
+
return this.id;
|
|
16
|
+
}
|
|
17
|
+
}
|