uws-react-native 0.0.9 → 0.0.11
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/README.md +134 -9
- package/cpp/UwsReactNativeModule.h +77 -0
- package/cpp/app/TemplatedAppObject.h +28 -0
- package/cpp/app/WebSocketBehaviorImpl.h +48 -0
- package/cpp/app/WebSocketObject.h +64 -0
- package/lib/commonjs/_internal/native-modules/NativeUwsReactNative.js.map +1 -1
- package/lib/commonjs/modules/CompressOptions.js +89 -101
- package/lib/commonjs/modules/CompressOptions.js.map +1 -1
- package/lib/commonjs/types/WebSocketBehavior.js +6 -0
- package/lib/commonjs/types/WebSocketBehavior.js.map +1 -0
- package/lib/module/_internal/native-modules/NativeUwsReactNative.js.map +1 -1
- package/lib/module/modules/CompressOptions.js +85 -101
- package/lib/module/modules/CompressOptions.js.map +1 -1
- package/lib/module/types/WebSocketBehavior.js +4 -0
- package/lib/module/types/WebSocketBehavior.js.map +1 -0
- package/lib/typescript/commonjs/_internal/native-modules/NativeUwsReactNative.d.ts +76 -0
- package/lib/typescript/commonjs/_internal/native-modules/NativeUwsReactNative.d.ts.map +1 -1
- package/lib/typescript/commonjs/modules/CompressOptions.d.ts +81 -0
- package/lib/typescript/commonjs/modules/CompressOptions.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/HttpResponse.d.ts +4 -4
- package/lib/typescript/commonjs/types/WebSocket.d.ts +42 -43
- package/lib/typescript/commonjs/types/WebSocket.d.ts.map +1 -1
- package/lib/typescript/commonjs/types/WebSocketBehavior.d.ts +101 -0
- package/lib/typescript/commonjs/types/WebSocketBehavior.d.ts.map +1 -0
- package/lib/typescript/module/_internal/native-modules/NativeUwsReactNative.d.ts +76 -0
- package/lib/typescript/module/_internal/native-modules/NativeUwsReactNative.d.ts.map +1 -1
- package/lib/typescript/module/modules/CompressOptions.d.ts +81 -0
- package/lib/typescript/module/modules/CompressOptions.d.ts.map +1 -1
- package/lib/typescript/module/types/HttpResponse.d.ts +4 -4
- package/lib/typescript/module/types/WebSocket.d.ts +42 -43
- package/lib/typescript/module/types/WebSocket.d.ts.map +1 -1
- package/lib/typescript/module/types/WebSocketBehavior.d.ts +101 -0
- package/lib/typescript/module/types/WebSocketBehavior.d.ts.map +1 -0
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_internal/native-modules/NativeUwsReactNative.ts +95 -0
- package/src/modules/CompressOptions.ts +101 -101
- package/src/types/HttpResponse.ts +4 -4
- package/src/types/TemplatedApp.ts +3 -3
- package/src/types/WebSocket.ts +59 -60
- package/src/types/WebSocketBehavior.ts +161 -0
- package/src/types/index.ts +1 -1
- package/lib/commonjs/types/WebSocketBehaviour.js +0 -139
- package/lib/commonjs/types/WebSocketBehaviour.js.map +0 -1
- package/lib/module/types/WebSocketBehaviour.js +0 -139
- package/lib/module/types/WebSocketBehaviour.js.map +0 -1
- package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts +0 -1
- package/lib/typescript/commonjs/types/WebSocketBehaviour.d.ts.map +0 -1
- package/lib/typescript/module/types/WebSocketBehaviour.d.ts +0 -1
- package/lib/typescript/module/types/WebSocketBehaviour.d.ts.map +0 -1
- package/src/types/WebSocketBehaviour.ts +0 -137
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSocketBehavior.d.ts","sourceRoot":"","sources":["../../../../src/types/WebSocketBehavior.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EACX,WAAW,EACX,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EACX,YAAY,EACZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EACX,SAAS,EACT,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EACX,mBAAmB,EACnB,MAAM,uBAAuB,CAAA;AAE9B;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,QAAQ;IAC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QAAQ,CAAC,EACvB,OAAO,EAAE,WAAW,KAChB,IAAI,CAAC;IAEV;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;OAEG;IACH,YAAY,CAAC,EAAE,CACd,EAAE,EAAE,SAAS,CAAC,QAAQ,CAAC,EACvB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,KACZ,IAAI,CAAC;IAEV;;OAEG;IACH,OAAO,CAAC,EAAE,CACT,GAAG,EAAE,YAAY,EACjB,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,mBAAmB,KACxB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
|
@@ -16,6 +16,82 @@ export interface Spec extends TurboModule {
|
|
|
16
16
|
body: unknown, contentType: string) => unknown;
|
|
17
17
|
_us_listen_socket_close: (id: CodegenTypes.Int32) => void;
|
|
18
18
|
_us_socket_local_port: (id: CodegenTypes.Int32) => number;
|
|
19
|
+
/**
|
|
20
|
+
* No compression (always a good idea if you operate using an efficient binary protocol)
|
|
21
|
+
*/
|
|
22
|
+
DISABLED: () => number;
|
|
23
|
+
/**
|
|
24
|
+
* Zero memory overhead compression.
|
|
25
|
+
*/
|
|
26
|
+
SHARED_COMPRESSOR: () => number;
|
|
27
|
+
/**
|
|
28
|
+
* Zero memory overhead decompression.
|
|
29
|
+
*/
|
|
30
|
+
SHARED_DECOMPRESSOR: () => number;
|
|
31
|
+
/**
|
|
32
|
+
* Sliding dedicated compress window, requires 3KB of memory per socket
|
|
33
|
+
*/
|
|
34
|
+
DEDICATED_COMPRESSOR_3KB: () => number;
|
|
35
|
+
/**
|
|
36
|
+
* Sliding dedicated compress window, requires 4KB of memory per socket
|
|
37
|
+
*/
|
|
38
|
+
DEDICATED_COMPRESSOR_4KB: () => number;
|
|
39
|
+
/**
|
|
40
|
+
* Sliding dedicated compress window, requires 8KB of memory per socket
|
|
41
|
+
*/
|
|
42
|
+
DEDICATED_COMPRESSOR_8KB: () => number;
|
|
43
|
+
/**
|
|
44
|
+
* Sliding dedicated compress window, requires 16KB of memory per socket
|
|
45
|
+
*/
|
|
46
|
+
DEDICATED_COMPRESSOR_16KB: () => number;
|
|
47
|
+
/**
|
|
48
|
+
* Sliding dedicated compress window, requires 32KB of memory per socket
|
|
49
|
+
*/
|
|
50
|
+
DEDICATED_COMPRESSOR_32KB: () => number;
|
|
51
|
+
/**
|
|
52
|
+
* Sliding dedicated compress window, requires 64KB of memory per socket
|
|
53
|
+
*/
|
|
54
|
+
DEDICATED_COMPRESSOR_64KB: () => number;
|
|
55
|
+
/**
|
|
56
|
+
* Sliding dedicated compress window, requires 128KB of memory per socket
|
|
57
|
+
*/
|
|
58
|
+
DEDICATED_COMPRESSOR_128KB: () => number;
|
|
59
|
+
/**
|
|
60
|
+
* Sliding dedicated compress window, requires 256KB of memory per socket
|
|
61
|
+
*/
|
|
62
|
+
DEDICATED_COMPRESSOR_256KB: () => number;
|
|
63
|
+
/**
|
|
64
|
+
* Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
|
|
65
|
+
*/
|
|
66
|
+
DEDICATED_DECOMPRESSOR_32KB: () => number;
|
|
67
|
+
/**
|
|
68
|
+
* Sliding dedicated decompress window, requires 16KB of memory per socket (plus about 23KB)
|
|
69
|
+
*/
|
|
70
|
+
DEDICATED_DECOMPRESSOR_16KB: () => number;
|
|
71
|
+
/**
|
|
72
|
+
* Sliding dedicated decompress window, requires 8KB of memory per socket (plus about 23KB)
|
|
73
|
+
*/
|
|
74
|
+
DEDICATED_DECOMPRESSOR_8KB: () => number;
|
|
75
|
+
/**
|
|
76
|
+
* Sliding dedicated decompress window, requires 4KB of memory per socket (plus about 23KB)
|
|
77
|
+
*/
|
|
78
|
+
DEDICATED_DECOMPRESSOR_4KB: () => number;
|
|
79
|
+
/**
|
|
80
|
+
* Sliding dedicated decompress window, requires 2KB of memory per socket (plus about 23KB)
|
|
81
|
+
*/
|
|
82
|
+
DEDICATED_DECOMPRESSOR_2KB: () => number;
|
|
83
|
+
/**
|
|
84
|
+
* Sliding dedicated decompress window, requires 1KB of memory per socket (plus about 23KB)
|
|
85
|
+
*/
|
|
86
|
+
DEDICATED_DECOMPRESSOR_1KB: () => number;
|
|
87
|
+
/**
|
|
88
|
+
* Sliding dedicated decompress window, requires 512B of memory per socket (plus about 23KB)
|
|
89
|
+
*/
|
|
90
|
+
DEDICATED_DECOMPRESSOR_512B: () => number;
|
|
91
|
+
/**
|
|
92
|
+
* Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
|
|
93
|
+
*/
|
|
94
|
+
DEDICATED_DECOMPRESSOR: () => number;
|
|
19
95
|
}
|
|
20
96
|
declare const _default: Spec;
|
|
21
97
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeUwsReactNative.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/native-modules/NativeUwsReactNative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,MAAM,cAAc,CAAA;AAErB;;GAEG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IACxC,GAAG,EAAE;IACJ;;OAEG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC,YAAY,KAClC,YAAY,CAAC,YAAY,CAAC;IAE/B,QAAQ,EAAE;IACT;;;OAGG;IACH,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,MAAM,KACf,OAAO,CAAC;IAEb,uBAAuB,EAAE,CACxB,EAAE,EAAE,YAAY,CAAC,KAAK,KAElB,IAAI,CAAC;IAEV,qBAAqB,EAAE,CACtB,EAAE,EAAE,YAAY,CAAC,KAAK,KAElB,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeUwsReactNative.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/native-modules/NativeUwsReactNative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK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MAAM,MAAM,CAAC;IAEzC;;OAEG;IACH,0BAA0B,EAAE,MAAM,MAAM,CAAC;IAEzC;;OAEG;IACH,2BAA2B,EAAE,MAAM,MAAM,CAAC;IAE1C;;OAEG;IACH,sBAAsB,EAAE,MAAM,MAAM,CAAC;CACrC;;AAED,wBAEC"}
|
|
@@ -1 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket compression options. Combine any compressor with any decompressor using bitwise OR.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum CompressOptions {
|
|
5
|
+
/**
|
|
6
|
+
* No compression (always a good idea if you operate using an efficient binary protocol)
|
|
7
|
+
*/
|
|
8
|
+
DISABLED,
|
|
9
|
+
/**
|
|
10
|
+
* Zero memory overhead compression.
|
|
11
|
+
*/
|
|
12
|
+
SHARED_COMPRESSOR,
|
|
13
|
+
/**
|
|
14
|
+
* Zero memory overhead decompression.
|
|
15
|
+
*/
|
|
16
|
+
SHARED_DECOMPRESSOR,
|
|
17
|
+
/**
|
|
18
|
+
* Sliding dedicated compress window, requires 3KB of memory per socket
|
|
19
|
+
*/
|
|
20
|
+
DEDICATED_COMPRESSOR_3KB,
|
|
21
|
+
/**
|
|
22
|
+
* Sliding dedicated compress window, requires 4KB of memory per socket
|
|
23
|
+
*/
|
|
24
|
+
DEDICATED_COMPRESSOR_4KB,
|
|
25
|
+
/**
|
|
26
|
+
* Sliding dedicated compress window, requires 8KB of memory per socket
|
|
27
|
+
*/
|
|
28
|
+
DEDICATED_COMPRESSOR_8KB,
|
|
29
|
+
/**
|
|
30
|
+
* Sliding dedicated compress window, requires 16KB of memory per socket
|
|
31
|
+
*/
|
|
32
|
+
DEDICATED_COMPRESSOR_16KB,
|
|
33
|
+
/**
|
|
34
|
+
* Sliding dedicated compress window, requires 32KB of memory per socket
|
|
35
|
+
*/
|
|
36
|
+
DEDICATED_COMPRESSOR_32KB,
|
|
37
|
+
/**
|
|
38
|
+
* Sliding dedicated compress window, requires 64KB of memory per socket
|
|
39
|
+
*/
|
|
40
|
+
DEDICATED_COMPRESSOR_64KB,
|
|
41
|
+
/**
|
|
42
|
+
* Sliding dedicated compress window, requires 128KB of memory per socket
|
|
43
|
+
*/
|
|
44
|
+
DEDICATED_COMPRESSOR_128KB,
|
|
45
|
+
/**
|
|
46
|
+
* Sliding dedicated compress window, requires 256KB of memory per socket
|
|
47
|
+
*/
|
|
48
|
+
DEDICATED_COMPRESSOR_256KB,
|
|
49
|
+
/**
|
|
50
|
+
* Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
|
|
51
|
+
*/
|
|
52
|
+
DEDICATED_DECOMPRESSOR_32KB,
|
|
53
|
+
/**
|
|
54
|
+
* Sliding dedicated decompress window, requires 16KB of memory per socket (plus about 23KB)
|
|
55
|
+
*/
|
|
56
|
+
DEDICATED_DECOMPRESSOR_16KB,
|
|
57
|
+
/**
|
|
58
|
+
* Sliding dedicated decompress window, requires 8KB of memory per socket (plus about 23KB)
|
|
59
|
+
*/
|
|
60
|
+
DEDICATED_DECOMPRESSOR_8KB,
|
|
61
|
+
/**
|
|
62
|
+
* Sliding dedicated decompress window, requires 4KB of memory per socket (plus about 23KB)
|
|
63
|
+
*/
|
|
64
|
+
DEDICATED_DECOMPRESSOR_4KB,
|
|
65
|
+
/**
|
|
66
|
+
* Sliding dedicated decompress window, requires 2KB of memory per socket (plus about 23KB)
|
|
67
|
+
*/
|
|
68
|
+
DEDICATED_DECOMPRESSOR_2KB,
|
|
69
|
+
/**
|
|
70
|
+
* Sliding dedicated decompress window, requires 1KB of memory per socket (plus about 23KB)
|
|
71
|
+
*/
|
|
72
|
+
DEDICATED_DECOMPRESSOR_1KB,
|
|
73
|
+
/**
|
|
74
|
+
* Sliding dedicated decompress window, requires 512B of memory per socket (plus about 23KB)
|
|
75
|
+
*/
|
|
76
|
+
DEDICATED_DECOMPRESSOR_512B,
|
|
77
|
+
/**
|
|
78
|
+
* Sliding dedicated decompress window, requires 32KB of memory per socket (plus about 23KB)
|
|
79
|
+
*/
|
|
80
|
+
DEDICATED_DECOMPRESSOR
|
|
81
|
+
}
|
|
1
82
|
//# sourceMappingURL=CompressOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompressOptions.d.ts","sourceRoot":"","sources":["../../../../src/modules/CompressOptions.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"CompressOptions.d.ts","sourceRoot":"","sources":["../../../../src/modules/CompressOptions.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,eAAe;IAC1B;;OAEG;IACH,QAA8C;IAE9C;;OAEG;IACH,iBAA8D;IAE9D;;OAEG;IACH,mBAAkE;IAElE;;OAEG;IACH,wBAA0E;IAE1E;;OAEG;IACH,wBAA0E;IAE1E;;OAEG;IACH,wBAA0E;IAE1E;;OAEG;IACH,yBAA4E;IAE5E;;OAEG;IACH,yBAA4E;IAE5E;;OAEG;IACH,yBAA4E;IAE5E;;OAEG;IACH,0BAA8E;IAE9E;;OAEG;IACH,0BAA8E;IAE9E;;OAEG;IACH,2BAAgF;IAEhF;;OAEG;IACH,2BAAgF;IAEhF;;OAEG;IACH,0BAA8E;IAE9E;;OAEG;IACH,0BAA8E;IAE9E;;OAEG;IACH,0BAA8E;IAE9E;;OAEG;IACH,0BAA8E;IAE9E;;OAEG;IACH,2BAAgF;IAEhF;;OAEG;IACH,sBAAuE;CACvE"}
|
|
@@ -110,9 +110,9 @@ export interface HttpResponse {
|
|
|
110
110
|
* })
|
|
111
111
|
*
|
|
112
112
|
* if(!isAborted) {
|
|
113
|
-
* res.onFullData(
|
|
113
|
+
* res.onFullData(data => {
|
|
114
114
|
* if(!isAborted) {
|
|
115
|
-
* res.end(`Body size is ${
|
|
115
|
+
* res.end(`Body size is ${data.byteLength}`)
|
|
116
116
|
* }
|
|
117
117
|
* })
|
|
118
118
|
* }
|
|
@@ -121,14 +121,14 @@ export interface HttpResponse {
|
|
|
121
121
|
* })
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
124
|
-
onFullData(handler: (
|
|
124
|
+
onFullData(handler: (data: ArrayBuffer) => void): void;
|
|
125
125
|
/**
|
|
126
126
|
* Similar to `onFullData`, but it is for reading HTTP request body data in raw text.
|
|
127
127
|
*
|
|
128
128
|
* This is an alternative method to read ArrayBuffer chunk in string because the TextDecoder is
|
|
129
129
|
* missing in React Native 0.84 and older.
|
|
130
130
|
*/
|
|
131
|
-
onFullDataText(handler: (
|
|
131
|
+
onFullDataText(handler: (data: string) => void): void;
|
|
132
132
|
/**
|
|
133
133
|
* Pause HTTP request body streaming (throttle).
|
|
134
134
|
* Some buffered data may still be sent to onData.
|
|
@@ -3,80 +3,71 @@ import type { RecognizedString } from "./RecognizedString";
|
|
|
3
3
|
* A WebSocket connection that is valid from open to close event.
|
|
4
4
|
* Read more about this in the user manual.
|
|
5
5
|
*/
|
|
6
|
-
export interface WebSocket {
|
|
6
|
+
export interface WebSocket<UserData> {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Make sure you properly understand the concept of backpressure. Check the backpressure example file.
|
|
8
|
+
* Forcefully closes this WebSocket. Immediately calls the close handler.
|
|
9
|
+
* No WebSocket close message is sent.
|
|
11
10
|
*/
|
|
12
|
-
|
|
11
|
+
close(): void;
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* See `HttpResponse.cork`.
|
|
14
|
+
* Takes a function in which the socket is corked (packing many sends into one single syscall/SSL block)
|
|
16
15
|
*/
|
|
17
|
-
|
|
16
|
+
cork(cb: () => void): WebSocket<UserData>;
|
|
18
17
|
/**
|
|
19
18
|
* Gracefully closes this WebSocket. Immediately calls the close handler.
|
|
20
19
|
* A WebSocket close message is sent with code and shortMessage.
|
|
21
20
|
*/
|
|
22
21
|
end(code?: number, shortMessage?: RecognizedString): void;
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
close(): void;
|
|
28
|
-
/**
|
|
29
|
-
* Sends a ping control message. Returns sendStatus similar to WebSocket.send (regarding backpressure). This helper function correlates to WebSocket::send(message, uWS::OpCode::PING, ...) in C++.
|
|
23
|
+
* Returns the bytes buffered in backpressure. This is similar to the bufferedAmount property in the browser counterpart.
|
|
24
|
+
* Check backpressure example.
|
|
30
25
|
*/
|
|
31
|
-
|
|
26
|
+
getBufferedAmount(): number;
|
|
32
27
|
/**
|
|
33
|
-
*
|
|
28
|
+
* Returns the remote IP address. Note that the returned IP is binary, not text.
|
|
29
|
+
*
|
|
30
|
+
* IPv4 is 4 byte long and can be converted to text by printing every byte as a digit between 0 and 255.
|
|
31
|
+
* IPv6 is 16 byte long and can be converted to text in similar ways, but you typically print digits in HEX.
|
|
32
|
+
*
|
|
33
|
+
* See getRemoteAddressAsText() for a text version.
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
getRemoteAddress(): ArrayBuffer;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Returns the remote IP address as text.
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
getRemoteAddressAsText(): string;
|
|
40
40
|
/**
|
|
41
|
-
* Returns
|
|
41
|
+
* Returns the remote port number.
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
getRemotePort(): number;
|
|
44
44
|
/**
|
|
45
45
|
* Returns a list of topics this websocket is subscribed to.
|
|
46
46
|
*/
|
|
47
47
|
getTopics(): string[];
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* Order is guaranteed since v20.
|
|
51
|
-
*/
|
|
52
|
-
publish(topic: RecognizedString, message: RecognizedString, isBinary?: boolean, compress?: boolean): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* See `HttpResponse.cork`. Takes a function in which the socket is corked (packing many sends into one single syscall/SSL block)
|
|
49
|
+
* Returns the UserData object.
|
|
55
50
|
*/
|
|
56
|
-
|
|
51
|
+
getUserData(): UserData;
|
|
57
52
|
/**
|
|
58
|
-
* Returns
|
|
59
|
-
*
|
|
60
|
-
* IPv4 is 4 byte long and can be converted to text by printing every byte as a digit between 0 and 255.
|
|
61
|
-
* IPv6 is 16 byte long and can be converted to text in similar ways, but you typically print digits in HEX.
|
|
62
|
-
*
|
|
63
|
-
* See getRemoteAddressAsText() for a text version.
|
|
64
|
-
*
|
|
65
|
-
* @experimental It's an experimental due to unstable of ArrayBuffer support from React Native.
|
|
53
|
+
* Returns whether this websocket is subscribed to topic.
|
|
66
54
|
*/
|
|
67
|
-
|
|
55
|
+
isSubscribed(topic: RecognizedString): boolean;
|
|
68
56
|
/**
|
|
69
|
-
* Returns
|
|
57
|
+
* Sends a ping control message. Returns sendStatus similar to WebSocket.send (regarding backpressure). This helper function correlates to WebSocket::send(message, uWS::OpCode::PING, ...) in C++.
|
|
70
58
|
*/
|
|
71
|
-
|
|
59
|
+
ping(message?: RecognizedString): number;
|
|
72
60
|
/**
|
|
73
|
-
*
|
|
61
|
+
* Publish a message under topic. Backpressure is managed according to maxBackpressure, closeOnBackpressureLimit settings.
|
|
62
|
+
* Order is guaranteed since v20.
|
|
74
63
|
*/
|
|
75
|
-
|
|
64
|
+
publish(topic: RecognizedString, message: RecognizedString, isBinary?: boolean, compress?: boolean): boolean;
|
|
76
65
|
/**
|
|
77
|
-
* Returns
|
|
66
|
+
* Sends a message. Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure that will drain over time. You can check backpressure before or after sending by calling getBufferedAmount().
|
|
67
|
+
*
|
|
68
|
+
* Make sure you properly understand the concept of backpressure. Check the backpressure example file.
|
|
78
69
|
*/
|
|
79
|
-
|
|
70
|
+
send(message: RecognizedString, isBinary?: boolean, compress?: boolean): number;
|
|
80
71
|
/**
|
|
81
72
|
* Sends the first fragment of a fragmented message. Use for sending large messages in chunks.
|
|
82
73
|
* Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
|
|
@@ -92,5 +83,13 @@ export interface WebSocket {
|
|
|
92
83
|
* Returns 1 for success, 2 for dropped due to backpressure limit, and 0 for built up backpressure.
|
|
93
84
|
*/
|
|
94
85
|
sendLastFragment(message: RecognizedString, compress?: boolean): number;
|
|
86
|
+
/**
|
|
87
|
+
* Subscribe to a topic.
|
|
88
|
+
*/
|
|
89
|
+
subscribe(topic: RecognizedString): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Unsubscribe from a topic. Returns true on success, if the WebSocket was subscribed.
|
|
92
|
+
*/
|
|
93
|
+
unsubscribe(topic: RecognizedString): boolean;
|
|
95
94
|
}
|
|
96
95
|
//# sourceMappingURL=WebSocket.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocket.d.ts","sourceRoot":"","sources":["../../../../src/types/WebSocket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,MAAM,oBAAoB,CAAA;AAE3B;;;GAGG;AACH,MAAM,WAAW,SAAS;
|
|
1
|
+
{"version":3,"file":"WebSocket.d.ts","sourceRoot":"","sources":["../../../../src/types/WebSocket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,gBAAgB,EAChB,MAAM,oBAAoB,CAAA;AAE3B;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,QAAQ;IAClC;;;OAGM;IACN,KAAK,IAAK,IAAI,CAAC;IAEf;;;OAGG;IACH,IAAI,CACH,EAAE,EAAE,MAAM,IAAI,GACX,SAAS,CAAC,QAAQ,CAAC,CAAC;IAExB;;;OAGM;IACN,GAAG,CACF,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,gBAAgB,GAC5B,IAAI,CAAC;IAET;;;OAGM;IACN,iBAAiB,IAAK,MAAM,CAAC;IAE7B;;;;;;;OAOM;IACN,gBAAgB,IAAK,WAAW,CAAC;IAEjC;;OAEG;IACH,sBAAsB,IAAK,MAAM,CAAC;IAElC;;OAEG;IACH,aAAa,IAAK,MAAM,CAAC;IAEzB;;OAEG;IACH,SAAS,IAAK,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,WAAW,IAAK,QAAQ,CAAC;IAEzB;;OAEG;IACH,YAAY,CACX,KAAK,EAAE,gBAAgB,GACpB,OAAO,CAAC;IAEZ;;OAEG;IACH,IAAI,CACH,OAAO,CAAC,EAAE,gBAAgB,GACvB,MAAM,CAAC;IAEX;;;OAGM;IACN,OAAO,CACN,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,gBAAgB,EACzB,QAAQ,CAAC,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,OAAO,GACf,OAAO,CAAC;IAEZ;;;;OAIM;IACN,IAAI,CACH,OAAO,EAAE,gBAAgB,EACzB,QAAQ,CAAC,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,OAAO,GACf,MAAM,CAAC;IAEX;;;OAGM;IACN,iBAAiB,CAChB,OAAO,EAAE,gBAAgB,EACzB,QAAQ,CAAC,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,OAAO,GACf,MAAM,CAAC;IAEX;;;OAGM;IACN,YAAY,CACX,OAAO,EAAE,gBAAgB,EACzB,QAAQ,CAAC,EAAE,OAAO,GACf,MAAM,CAAC;IAEX;;;OAGM;IACN,gBAAgB,CACf,OAAO,EAAE,gBAAgB,EACzB,QAAQ,CAAC,EAAE,OAAO,GACf,MAAM,CAAC;IAEX;;OAEG;IACH,SAAS,CACR,KAAK,EAAE,gBAAgB,GACpB,OAAO,CAAC;IAEZ;;OAEG;IACH,WAAW,CACV,KAAK,EAAE,gBAAgB,GACpB,OAAO,CAAC;CACZ"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { CompressOptions } from "../modules/CompressOptions";
|
|
2
|
+
import type { HttpRequest } from "./HttpRequest";
|
|
3
|
+
import type { HttpResponse } from "./HttpResponse";
|
|
4
|
+
import type { WebSocket } from "./WebSocket";
|
|
5
|
+
import type { us_socket_context_t } from "./us_socket_context_t";
|
|
6
|
+
/**
|
|
7
|
+
* A structure holding settings and handlers for a WebSocket URL route handler.
|
|
8
|
+
*/
|
|
9
|
+
export interface WebSocketBehavior<UserData> {
|
|
10
|
+
/**
|
|
11
|
+
* Handler for close event, no matter if error, timeout or graceful close.
|
|
12
|
+
* You may not use WebSocket after this event.
|
|
13
|
+
* Do not send on this WebSocket from within here, it is closed.
|
|
14
|
+
*/
|
|
15
|
+
close?: (ws: WebSocket<UserData>, code: number, message: ArrayBuffer) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Whether or not we should automatically close the socket when a message is dropped due to backpressure. Defaults to false.
|
|
18
|
+
*/
|
|
19
|
+
closeOnBackpressureLimit?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* What permessage-deflate compression to use. uWS.DISABLED, uWS.SHARED_COMPRESSOR or any of the uWS.DEDICATED_COMPRESSOR_xxxKB. Defaults to uWS.DISABLED.
|
|
22
|
+
*
|
|
23
|
+
* Combine any compressor with any decompressor using bitwise OR.
|
|
24
|
+
*/
|
|
25
|
+
compression?: CompressOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Handler for when WebSocket backpressure drains.
|
|
28
|
+
* Check `ws.getBufferedAmount()`.
|
|
29
|
+
* Use this to guide / drive your backpressure throttling.
|
|
30
|
+
*/
|
|
31
|
+
drain?: (ws: WebSocket<UserData>) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Handler for a dropped WebSocket message.
|
|
34
|
+
* Messages can be dropped due to specified backpressure settings.
|
|
35
|
+
* Messages are given as ArrayBuffer no matter if they are binary or not.
|
|
36
|
+
* Given ArrayBuffer is valid during the lifetime of this callback
|
|
37
|
+
* (until first await or return) and will be neutered.
|
|
38
|
+
*/
|
|
39
|
+
dropped?: (ws: WebSocket<UserData>, message: ArrayBuffer, isBinary: boolean) => void | Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum amount of seconds that may pass without sending or getting a message. Connection is closed if this timeout passes.
|
|
42
|
+
* Resolution (granularity) for timeouts are typically 4 seconds, rounded to closest.
|
|
43
|
+
*
|
|
44
|
+
* Disable by using 0. Defaults to 120.
|
|
45
|
+
*/
|
|
46
|
+
idleTimeout?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Maximum length of allowed backpressure per socket when publishing or sending messages.
|
|
49
|
+
* Slow receivers with too high backpressure will be skipped until they catch up or timeout.
|
|
50
|
+
*
|
|
51
|
+
* Defaults to 64 * 1024.
|
|
52
|
+
*/
|
|
53
|
+
maxBackpressure?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Maximum number of minutes a WebSocket may be connected before being closed by the server.
|
|
56
|
+
*
|
|
57
|
+
* 0 disables the feature. Valid values are 0 and 1-239.
|
|
58
|
+
*/
|
|
59
|
+
maxLifetime?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Maximum length of received message.
|
|
62
|
+
* If a client tries to send you a message larger than this, the connection is immediately closed.
|
|
63
|
+
*
|
|
64
|
+
* Defaults to 16 * 1024.
|
|
65
|
+
*/
|
|
66
|
+
maxPayloadLength?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Handler for a WebSocket message.
|
|
69
|
+
* Messages are given as ArrayBuffer no matter if they are binary or not.
|
|
70
|
+
*
|
|
71
|
+
* Given ArrayBuffer is valid during the lifetime of this callback (until first await or return) and will be neutered.
|
|
72
|
+
*/
|
|
73
|
+
message?: (ws: WebSocket<UserData>, message: ArrayBuffer, isBinary: boolean) => void | Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Handler for new WebSocket connection.
|
|
76
|
+
* WebSocket is valid from open to close, no errors.
|
|
77
|
+
*/
|
|
78
|
+
open?: (ws: WebSocket<UserData>) => void | Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Handler for received ping control message.
|
|
81
|
+
* You do not need to handle this, pong messages are automatically sent as per the standard.
|
|
82
|
+
*/
|
|
83
|
+
ping?: (ws: WebSocket<UserData>, message: ArrayBuffer) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Handler for received pong control message.
|
|
86
|
+
*/
|
|
87
|
+
pong?: (ws: WebSocket<UserData>, message: ArrayBuffer) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Whether or not we should automatically send pings to uphold a stable connection given whatever `idleTimeout`.
|
|
90
|
+
*/
|
|
91
|
+
sendPingsAutomatically?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Handler for subscription changes.
|
|
94
|
+
*/
|
|
95
|
+
subscription?: (ws: WebSocket<UserData>, topic: ArrayBuffer, newCount: number, oldCount: number) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Upgrade handler used to intercept HTTP upgrade requests and potentially upgrade to WebSocket.
|
|
98
|
+
*/
|
|
99
|
+
upgrade?: (res: HttpResponse, req: HttpRequest, context: us_socket_context_t) => void | Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=WebSocketBehavior.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSocketBehavior.d.ts","sourceRoot":"","sources":["../../../../src/types/WebSocketBehavior.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,eAAe,EACf,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EACX,WAAW,EACX,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EACX,YAAY,EACZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EACX,SAAS,EACT,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EACX,mBAAmB,EACnB,MAAM,uBAAuB,CAAA;AAE9B;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,QAAQ;IAC1C;;;;OAIG;IACH,KAAK,CAAC,EAAE,CACP,EAAE,EAAE,SAAS,CAAC,QAAQ,CAAC,EACvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,KAChB,IAAI,CAAC;IAEV;;OAEG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC;;;;OAIG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B;;;;OAIG;IACH,KAAK,CAAC,EAAE,CACP,EAAE,EAAE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