@cnhongwei/react-native-mqtt 0.0.0-stage → 0.1.0
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 +20 -0
- package/README.md +169 -2
- package/README.zh-CN.md +100 -0
- package/ReactNativeMqtt.podspec +28 -0
- package/THIRD_PARTY_NOTICES.md +17 -0
- package/android/build.gradle +70 -0
- package/android/consumer-rules.pro +10 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/MqttOptionsParser.kt +176 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/MqttSession.kt +1006 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/PahoLogger.java +44 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/PahoMqttTransport.kt +399 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/ReactNativeMqttModule.kt +619 -0
- package/android/src/main/java/com/cnhongwei/reactnativemqtt/ReactNativeMqttPackage.kt +31 -0
- package/ios/ReactNativeMqtt.h +15 -0
- package/ios/ReactNativeMqtt.mm +1184 -0
- package/ios/ReactNativeMqttCocoaTransport.swift +782 -0
- package/ios/ReactNativeMqttConnAckProbe.swift +87 -0
- package/ios/ReactNativeMqttSession.swift +420 -0
- package/lib/module/NativeReactNativeMqtt.js +5 -0
- package/lib/module/NativeReactNativeMqtt.js.map +1 -0
- package/lib/module/client.js +555 -0
- package/lib/module/client.js.map +1 -0
- package/lib/module/errors.js +20 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/helpers.js +116 -0
- package/lib/module/helpers.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/validation.js +306 -0
- package/lib/module/validation.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeReactNativeMqtt.d.ts +154 -0
- package/lib/typescript/src/NativeReactNativeMqtt.d.ts.map +1 -0
- package/lib/typescript/src/client.d.ts +3 -0
- package/lib/typescript/src/client.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts +18 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/helpers.d.ts +5 -0
- package/lib/typescript/src/helpers.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +161 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/validation.d.ts +13 -0
- package/lib/typescript/src/validation.d.ts.map +1 -0
- package/package.json +188 -4
- package/react-native.config.js +1 -0
- package/src/NativeReactNativeMqtt.ts +173 -0
- package/src/client.ts +859 -0
- package/src/errors.ts +51 -0
- package/src/helpers.ts +151 -0
- package/src/index.ts +30 -0
- package/src/types.ts +184 -0
- package/src/validation.ts +735 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TurboModuleRegistry,
|
|
3
|
+
type CodegenTypes,
|
|
4
|
+
type TurboModule,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
|
|
7
|
+
export type WireUserProperty = { key: string; value: string };
|
|
8
|
+
export type WireCapabilities = {
|
|
9
|
+
wireVersion: number;
|
|
10
|
+
platform: string;
|
|
11
|
+
protocolVersions: number[];
|
|
12
|
+
transports: string[];
|
|
13
|
+
supportsSessionPresent: boolean;
|
|
14
|
+
supportsDuplicateUserProperties: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type WireSessionOptions = {
|
|
17
|
+
host: string;
|
|
18
|
+
port: number;
|
|
19
|
+
protocolVersion?: number;
|
|
20
|
+
transport?: string;
|
|
21
|
+
path?: string;
|
|
22
|
+
clientId?: string;
|
|
23
|
+
username?: string;
|
|
24
|
+
password?: string;
|
|
25
|
+
keepAliveSeconds?: number;
|
|
26
|
+
connectTimeoutMs?: number;
|
|
27
|
+
operationTimeoutMs?: number;
|
|
28
|
+
disconnectTimeoutMs?: number;
|
|
29
|
+
reconnectEnabled?: boolean;
|
|
30
|
+
reconnectInitialDelayMs?: number;
|
|
31
|
+
reconnectMaxDelayMs?: number;
|
|
32
|
+
reconnectJitterRatio?: number;
|
|
33
|
+
tlsCaBase64?: string;
|
|
34
|
+
tlsP12Base64?: string;
|
|
35
|
+
tlsP12Password?: string;
|
|
36
|
+
tlsInsecure?: boolean;
|
|
37
|
+
tlsAllowInvalidHostnameForTesting?: boolean;
|
|
38
|
+
willTopic?: string;
|
|
39
|
+
willPayloadBase64?: string;
|
|
40
|
+
willQos?: number;
|
|
41
|
+
willRetained?: boolean;
|
|
42
|
+
cleanSession?: boolean;
|
|
43
|
+
cleanStart?: boolean;
|
|
44
|
+
sessionExpiryIntervalSeconds?: number;
|
|
45
|
+
receiveMaximum?: number;
|
|
46
|
+
userProperties?: WireUserProperty[];
|
|
47
|
+
maxQueuedMessages?: number;
|
|
48
|
+
maxQueuedBytes?: number;
|
|
49
|
+
maxMessageBytes?: number;
|
|
50
|
+
batchMaxMessages?: number;
|
|
51
|
+
batchMaxBytes?: number;
|
|
52
|
+
batchAckTimeoutMs?: number;
|
|
53
|
+
overflowPolicy?: string;
|
|
54
|
+
};
|
|
55
|
+
export type WireSubscribeOptions = {
|
|
56
|
+
qos?: number;
|
|
57
|
+
noLocal?: boolean;
|
|
58
|
+
retainAsPublished?: boolean;
|
|
59
|
+
retainHandling?: number;
|
|
60
|
+
};
|
|
61
|
+
export type WirePublishRequest = {
|
|
62
|
+
topic: string;
|
|
63
|
+
payloadBase64: string;
|
|
64
|
+
qos?: number;
|
|
65
|
+
retained?: boolean;
|
|
66
|
+
userProperties?: WireUserProperty[];
|
|
67
|
+
contentType?: string;
|
|
68
|
+
responseTopic?: string;
|
|
69
|
+
correlationDataBase64?: string;
|
|
70
|
+
messageExpiryIntervalSeconds?: number;
|
|
71
|
+
payloadFormatIndicator?: number;
|
|
72
|
+
};
|
|
73
|
+
export type WireConnAck = {
|
|
74
|
+
sessionPresent: boolean;
|
|
75
|
+
assignedClientId?: string;
|
|
76
|
+
reasonCode?: number;
|
|
77
|
+
reasonString?: string;
|
|
78
|
+
userProperties?: WireUserProperty[];
|
|
79
|
+
};
|
|
80
|
+
export type WireSnapshot = {
|
|
81
|
+
instanceId: string;
|
|
82
|
+
revision: number;
|
|
83
|
+
generation: number;
|
|
84
|
+
state: string;
|
|
85
|
+
lastConnAck: WireConnAck | null;
|
|
86
|
+
subscriptionsRevision: number;
|
|
87
|
+
subscriptionsStatus: string;
|
|
88
|
+
deliveryStatus: string;
|
|
89
|
+
};
|
|
90
|
+
export type WireMessage = {
|
|
91
|
+
instanceId: string;
|
|
92
|
+
generation: number;
|
|
93
|
+
topic: string;
|
|
94
|
+
payloadBase64: string;
|
|
95
|
+
qos: number;
|
|
96
|
+
retained: boolean;
|
|
97
|
+
userProperties?: WireUserProperty[];
|
|
98
|
+
contentType?: string;
|
|
99
|
+
responseTopic?: string;
|
|
100
|
+
correlationDataBase64?: string;
|
|
101
|
+
messageExpiryIntervalSeconds?: number;
|
|
102
|
+
payloadFormatIndicator?: number;
|
|
103
|
+
};
|
|
104
|
+
export type WireBatch = {
|
|
105
|
+
instanceId: string;
|
|
106
|
+
streamEpoch: number;
|
|
107
|
+
batchId: number;
|
|
108
|
+
messages: WireMessage[];
|
|
109
|
+
};
|
|
110
|
+
export type WireDiagnostic = {
|
|
111
|
+
instanceId: string;
|
|
112
|
+
generation: number;
|
|
113
|
+
code: string;
|
|
114
|
+
message: string;
|
|
115
|
+
operation?: string;
|
|
116
|
+
reasonCode?: number;
|
|
117
|
+
reasonString?: string;
|
|
118
|
+
metrics?: {
|
|
119
|
+
queuedMessages: number;
|
|
120
|
+
queuedBytes: number;
|
|
121
|
+
pendingOperations: number;
|
|
122
|
+
droppedMessages: number;
|
|
123
|
+
reconnectAttempts: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export type WireSubscriptionResult = {
|
|
127
|
+
generation: number;
|
|
128
|
+
intentRevision: number;
|
|
129
|
+
grantedQos: number;
|
|
130
|
+
reasonCode?: number;
|
|
131
|
+
};
|
|
132
|
+
export type WireIntentResult = { intentRevision: number };
|
|
133
|
+
|
|
134
|
+
export interface Spec extends TurboModule {
|
|
135
|
+
getCapabilities(): Promise<WireCapabilities>;
|
|
136
|
+
openSession(
|
|
137
|
+
instanceId: string,
|
|
138
|
+
options: WireSessionOptions
|
|
139
|
+
): Promise<WireSnapshot>;
|
|
140
|
+
connect(
|
|
141
|
+
instanceId: string
|
|
142
|
+
): Promise<{ snapshot: WireSnapshot; ack: WireConnAck }>;
|
|
143
|
+
disconnect(instanceId: string): Promise<WireSnapshot>;
|
|
144
|
+
close(instanceId: string): Promise<WireSnapshot>;
|
|
145
|
+
getSnapshot(instanceId: string): Promise<WireSnapshot>;
|
|
146
|
+
setSubscription(
|
|
147
|
+
instanceId: string,
|
|
148
|
+
filter: string,
|
|
149
|
+
options: WireSubscribeOptions,
|
|
150
|
+
intentRevision: number
|
|
151
|
+
): Promise<WireSubscriptionResult>;
|
|
152
|
+
removeSubscription(
|
|
153
|
+
instanceId: string,
|
|
154
|
+
filter: string,
|
|
155
|
+
intentRevision: number
|
|
156
|
+
): Promise<WireIntentResult>;
|
|
157
|
+
awaitSubscriptions(
|
|
158
|
+
instanceId: string,
|
|
159
|
+
generation: number,
|
|
160
|
+
desiredRevision: number
|
|
161
|
+
): Promise<WireSnapshot>;
|
|
162
|
+
publish(instanceId: string, request: WirePublishRequest): Promise<void>;
|
|
163
|
+
ackMessageBatch(
|
|
164
|
+
instanceId: string,
|
|
165
|
+
streamEpoch: number,
|
|
166
|
+
batchId: number
|
|
167
|
+
): Promise<void>;
|
|
168
|
+
readonly onSessionSnapshot: CodegenTypes.EventEmitter<WireSnapshot>;
|
|
169
|
+
readonly onMessageBatch: CodegenTypes.EventEmitter<WireBatch>;
|
|
170
|
+
readonly onDiagnostic: CodegenTypes.EventEmitter<WireDiagnostic>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export default TurboModuleRegistry.get<Spec>('ReactNativeMqtt');
|