@seriousme/opifex 2.2.0 → 2.4.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/README.md +7 -6
- package/bin/mqtt.ts +1 -1
- package/client/client.ts +62 -7
- package/client/context.ts +2 -2
- package/client/deps.ts +3 -3
- package/client/mod.ts +2 -2
- package/connNext/baseConnNext.ts +123 -0
- package/connNext/connNext.ts +44 -0
- package/deno/README.md +1 -1
- package/deno/denoConnToNext.ts +104 -0
- package/deno/tcpClient.ts +8 -24
- package/deno/tcpServer.test.ts +14 -103
- package/deno/tcpServer.ts +14 -6
- package/deno/tlsServer.test.ts +14 -58
- package/deno/tlsServer.ts +14 -6
- package/deno/wsServer.test.ts +15 -61
- package/deno/wsServer.ts +82 -32
- package/dev_utils/WebStreamEndpoint.ts +5 -0
- package/dev_utils/asyncStreamEndpoint.ts +5 -0
- package/dev_utils/asyncStreamPair.ts +109 -0
- package/dev_utils/asyncStreamPairToNext.ts +45 -0
- package/dev_utils/asyncStreamToNext.ts +64 -0
- package/dev_utils/connNextPair.test.ts +179 -0
- package/dev_utils/mockConn.ts +59 -29
- package/dev_utils/mockServer.ts +3 -4
- package/dev_utils/mod.ts +1 -2
- package/dev_utils/testClient.ts +64 -0
- package/dev_utils/webStreamPair.ts +3 -7
- package/dev_utils/webStreamPairToNext.ts +48 -0
- package/dev_utils/webStreamToNext.ts +54 -0
- package/dist/bin/mqtt.js +1 -1
- package/dist/bin/mqtt.js.map +1 -1
- package/dist/client/client.d.ts +24 -3
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +45 -5
- package/dist/client/client.js.map +1 -1
- package/dist/client/context.d.ts +2 -2
- package/dist/client/context.d.ts.map +1 -1
- package/dist/client/deps.d.ts +1 -1
- package/dist/client/deps.d.ts.map +1 -1
- package/dist/client/mod.d.ts +1 -1
- package/dist/client/mod.d.ts.map +1 -1
- package/dist/connNext/baseConnNext.d.ts +20 -0
- package/dist/connNext/baseConnNext.d.ts.map +1 -0
- package/dist/connNext/baseConnNext.js +95 -0
- package/dist/connNext/baseConnNext.js.map +1 -0
- package/dist/connNext/connNext.d.ts +43 -0
- package/dist/connNext/connNext.d.ts.map +1 -0
- package/dist/connNext/connNext.js +2 -0
- package/dist/connNext/connNext.js.map +1 -0
- package/dist/examples/authHandler.test.js +2 -2
- package/dist/examples/authHandler.test.js.map +1 -1
- package/dist/examples/mqtt+mqtts.test.d.ts +2 -0
- package/dist/examples/mqtt+mqtts.test.d.ts.map +1 -0
- package/dist/examples/mqtt+mqtts.test.js +104 -0
- package/dist/examples/mqtt+mqtts.test.js.map +1 -0
- package/dist/examples/mqtt.test.js +2 -2
- package/dist/examples/mqtt.test.js.map +1 -1
- package/dist/examples/mqtts.test.js +2 -2
- package/dist/examples/mqtts.test.js.map +1 -1
- package/dist/mqttConn/mqttConn.d.ts +5 -6
- package/dist/mqttConn/mqttConn.d.ts.map +1 -1
- package/dist/mqttConn/mqttConn.js +2 -3
- package/dist/mqttConn/mqttConn.js.map +1 -1
- package/dist/node/nodeSocketToNext.d.ts +17 -0
- package/dist/node/nodeSocketToNext.d.ts.map +1 -0
- package/dist/node/nodeSocketToNext.js +105 -0
- package/dist/node/nodeSocketToNext.js.map +1 -0
- package/dist/node/tcpClient.d.ts +4 -6
- package/dist/node/tcpClient.d.ts.map +1 -1
- package/dist/node/tcpClient.js +6 -21
- package/dist/node/tcpClient.js.map +1 -1
- package/dist/node/tcpServer.d.ts +8 -4
- package/dist/node/tcpServer.d.ts.map +1 -1
- package/dist/node/tcpServer.js +14 -6
- package/dist/node/tcpServer.js.map +1 -1
- package/dist/node/tlsServer.d.ts +7 -3
- package/dist/node/tlsServer.d.ts.map +1 -1
- package/dist/node/tlsServer.js +13 -5
- package/dist/node/tlsServer.js.map +1 -1
- package/dist/server/context.d.ts +5 -5
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/context.js +4 -1
- package/dist/server/context.js.map +1 -1
- package/dist/server/deps.d.ts +1 -1
- package/dist/server/deps.d.ts.map +1 -1
- package/dist/server/mod.d.ts +1 -1
- package/dist/server/mod.d.ts.map +1 -1
- package/dist/server/server.d.ts +3 -3
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +3 -3
- package/dist/utils/utils.d.ts +1 -2
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +3 -2
- package/dist/utils/utils.js.map +1 -1
- package/dist/web/webSocketToNext.d.ts +20 -0
- package/dist/web/webSocketToNext.d.ts.map +1 -0
- package/dist/web/webSocketToNext.js +125 -0
- package/dist/web/webSocketToNext.js.map +1 -0
- package/dist/web/wsClient.d.ts +3 -3
- package/dist/web/wsClient.d.ts.map +1 -1
- package/dist/web/wsClient.js +22 -7
- package/dist/web/wsClient.js.map +1 -1
- package/dist/web/wsClient.test.js +15 -0
- package/dist/web/wsClient.test.js.map +1 -1
- package/examples/README.md +21 -0
- package/examples/authHandler.test.ts +2 -2
- package/examples/mqtt+mqtts.test.ts +122 -0
- package/examples/mqtt.test.ts +2 -2
- package/examples/mqtts.test.ts +2 -2
- package/examples/webSocket.test.ts +10 -64
- package/examples/webSocketServer.ts +98 -0
- package/mqttConn/mqttConn.test.ts +6 -6
- package/mqttConn/mqttConn.ts +8 -9
- package/node/README.md +1 -1
- package/node/nodeSocketToNext.ts +124 -0
- package/node/tcpClient.ts +13 -27
- package/node/tcpServer.test.ts +12 -58
- package/node/tcpServer.ts +18 -8
- package/node/tlsServer.test.ts +11 -58
- package/node/tlsServer.ts +17 -7
- package/package.json +4 -3
- package/server/context.ts +9 -6
- package/server/deps.ts +1 -1
- package/server/mod.ts +1 -1
- package/server/server.ts +6 -6
- package/utils/utils.ts +3 -2
- package/web/webSocketToNext.ts +146 -0
- package/web/wsClient.test.ts +22 -0
- package/web/wsClient.ts +29 -9
- package/dev_utils/webStreamPair.test.ts +0 -171
- package/dist/node/wrapNodeSocket.d.ts +0 -12
- package/dist/node/wrapNodeSocket.d.ts.map +0 -1
- package/dist/node/wrapNodeSocket.js +0 -36
- package/dist/node/wrapNodeSocket.js.map +0 -1
- package/dist/socket/socket.d.ts +0 -58
- package/dist/socket/socket.d.ts.map +0 -1
- package/dist/socket/socket.js +0 -99
- package/dist/socket/socket.js.map +0 -1
- package/dist/web/webSocketStream.d.ts +0 -29
- package/dist/web/webSocketStream.d.ts.map +0 -1
- package/dist/web/webSocketStream.js +0 -69
- package/dist/web/webSocketStream.js.map +0 -1
- package/dist/web/wrapWebSocket.d.ts +0 -12
- package/dist/web/wrapWebSocket.d.ts.map +0 -1
- package/dist/web/wrapWebSocket.js +0 -41
- package/dist/web/wrapWebSocket.js.map +0 -1
- package/node/socket-node-stream.test.ts +0 -322
- package/node/socket-node-stream.ts +0 -174
- package/node/wrapNodeSocket.ts +0 -44
- package/socket/socket.test.ts +0 -91
- package/socket/socket.ts +0 -149
- package/web/webSocketStream.ts +0 -97
- package/web/wrapWebSocket.ts +0 -52
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ConnAddr, ConnNext } from "../connNext/connNext.ts";
|
|
2
|
+
import { createAsyncStreamPair } from "./asyncStreamPair.ts";
|
|
3
|
+
import { asyncStreamToNext } from "./asyncStreamToNext.ts";
|
|
4
|
+
|
|
5
|
+
export function createConnNextPair(): {
|
|
6
|
+
input: ConnNext;
|
|
7
|
+
output: ConnNext;
|
|
8
|
+
} {
|
|
9
|
+
const { input: asyncInput, output: asyncOutput } = createAsyncStreamPair();
|
|
10
|
+
|
|
11
|
+
const mockAddr: ConnAddr = {
|
|
12
|
+
transport: "tcp",
|
|
13
|
+
hostname: "127.0.0.1",
|
|
14
|
+
port: 1883,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const inputWrapper = asyncStreamToNext(asyncInput);
|
|
18
|
+
const outputWrapper = asyncStreamToNext(asyncOutput);
|
|
19
|
+
|
|
20
|
+
const input: ConnNext = {
|
|
21
|
+
remoteAddr: mockAddr,
|
|
22
|
+
localAddr: mockAddr,
|
|
23
|
+
read: (length: number | undefined) => inputWrapper.read(length),
|
|
24
|
+
write: (data: Uint8Array<ArrayBufferLike>) => inputWrapper.write(data),
|
|
25
|
+
[Symbol.asyncIterator]: () => inputWrapper[Symbol.asyncIterator](),
|
|
26
|
+
close: () => {
|
|
27
|
+
inputWrapper.close();
|
|
28
|
+
outputWrapper.close();
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const output: ConnNext = {
|
|
33
|
+
remoteAddr: mockAddr,
|
|
34
|
+
localAddr: mockAddr,
|
|
35
|
+
read: (length: number | undefined) => outputWrapper.read(length),
|
|
36
|
+
write: (data: Uint8Array<ArrayBufferLike>) => outputWrapper.write(data),
|
|
37
|
+
[Symbol.asyncIterator]: () => outputWrapper[Symbol.asyncIterator](),
|
|
38
|
+
close: () => {
|
|
39
|
+
outputWrapper.close();
|
|
40
|
+
inputWrapper.close();
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return { input, output };
|
|
45
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { BaseConnNext } from "../connNext/baseConnNext.ts";
|
|
2
|
+
import type { AsyncStreamEndpoint } from "./asyncStreamEndpoint.ts";
|
|
3
|
+
|
|
4
|
+
export class AsyncStreamConnNext extends BaseConnNext {
|
|
5
|
+
remoteAddr = undefined;
|
|
6
|
+
localAddr = undefined;
|
|
7
|
+
private reader: AsyncIterator<Uint8Array>;
|
|
8
|
+
private endPoint: AsyncStreamEndpoint;
|
|
9
|
+
|
|
10
|
+
constructor(endPoint: AsyncStreamEndpoint) {
|
|
11
|
+
super();
|
|
12
|
+
this.endPoint = endPoint;
|
|
13
|
+
// Haal de async iterator op uit de readable stream
|
|
14
|
+
this.reader = endPoint.readable[Symbol.asyncIterator]();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Haalt op exact moment van aanvragen één nieuwe chunk op via de iterator.
|
|
19
|
+
*/
|
|
20
|
+
protected async pullNextChunk(): Promise<Uint8Array | null> {
|
|
21
|
+
if (this.closed) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const { value, done } = await this.reader.next();
|
|
27
|
+
if (done || !value) {
|
|
28
|
+
this.closed = true;
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
} catch {
|
|
33
|
+
this.closed = true;
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async write(chunk: Uint8Array): Promise<void> {
|
|
39
|
+
if (this.closed) {
|
|
40
|
+
return Promise.reject(new Error("Pipe closed"));
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
await this.endPoint.write(chunk);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
this.closed = true;
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
close(): void {
|
|
51
|
+
if (!this.closed) {
|
|
52
|
+
this.closed = true;
|
|
53
|
+
try {
|
|
54
|
+
this.endPoint.close();
|
|
55
|
+
} catch (_err) {
|
|
56
|
+
/* swallow */
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function asyncStreamToNext(endPoint: AsyncStreamEndpoint) {
|
|
63
|
+
return new AsyncStreamConnNext(endPoint);
|
|
64
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import { createConnNextPair as asyncPair } from "./asyncStreamPairToNext.ts";
|
|
4
|
+
import { createConnNextPair as webPair } from "./webStreamPairToNext.ts";
|
|
5
|
+
|
|
6
|
+
const pairs = {
|
|
7
|
+
asyncStream: asyncPair,
|
|
8
|
+
webStream: webPair,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
for (const [label, createConnNextPair] of Object.entries(pairs)) {
|
|
12
|
+
test(`[${label}]:`, async (t) => {
|
|
13
|
+
await t.test("Echo server shuts down cleanly when client closes input", async () => {
|
|
14
|
+
const { input, output } = createConnNextPair();
|
|
15
|
+
|
|
16
|
+
// Run a simple background echo server using the Stream Next model
|
|
17
|
+
const echoPromise = (async () => {
|
|
18
|
+
while (true) {
|
|
19
|
+
const chunk = await output.read();
|
|
20
|
+
if (chunk === null) break; // End of stream reached
|
|
21
|
+
await output.write(chunk);
|
|
22
|
+
}
|
|
23
|
+
})();
|
|
24
|
+
|
|
25
|
+
// Client closes their side of the connection
|
|
26
|
+
input.close();
|
|
27
|
+
|
|
28
|
+
// The echo server loop should finish successfully without throwing
|
|
29
|
+
await assert.doesNotReject(echoPromise);
|
|
30
|
+
|
|
31
|
+
// The client's read call should now return null indicating EOF
|
|
32
|
+
const result = await input.read();
|
|
33
|
+
assert.strictEqual(result, null);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await t.test("Data written to input.write arrives at input.read", async () => {
|
|
37
|
+
const { input, output } = createConnNextPair();
|
|
38
|
+
|
|
39
|
+
// Background echo server
|
|
40
|
+
const echoPromise = (async () => {
|
|
41
|
+
while (true) {
|
|
42
|
+
const chunk = await output.read();
|
|
43
|
+
if (chunk === null) break;
|
|
44
|
+
await output.write(chunk);
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
|
|
48
|
+
const encoder = new TextEncoder();
|
|
49
|
+
const decoder = new TextDecoder();
|
|
50
|
+
const message = "Hello streaming world!";
|
|
51
|
+
|
|
52
|
+
// Write data from the client side
|
|
53
|
+
await input.write(encoder.encode(message));
|
|
54
|
+
|
|
55
|
+
// Read back the echoed message
|
|
56
|
+
const result = await input.read();
|
|
57
|
+
assert.notStrictEqual(result, null);
|
|
58
|
+
assert.strictEqual(decoder.decode(result!), message);
|
|
59
|
+
|
|
60
|
+
// Close the client side so the echo server finishes cleanly
|
|
61
|
+
input.close();
|
|
62
|
+
await assert.doesNotReject(echoPromise);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await t.test("Client detects when the echo server abruptly closes its end", async () => {
|
|
66
|
+
const { input, output } = createConnNextPair();
|
|
67
|
+
const encoder = new TextEncoder();
|
|
68
|
+
|
|
69
|
+
// Run a server loop that can be manually stopped by closing 'output'
|
|
70
|
+
const echoPromise = (async () => {
|
|
71
|
+
while (true) {
|
|
72
|
+
const chunk = await output.read();
|
|
73
|
+
if (chunk === null) break;
|
|
74
|
+
await output.write(chunk);
|
|
75
|
+
}
|
|
76
|
+
})();
|
|
77
|
+
|
|
78
|
+
// --- Simulate Server Shutdown ---
|
|
79
|
+
// The server abruptly closes its end
|
|
80
|
+
output.close();
|
|
81
|
+
await assert.doesNotReject(echoPromise);
|
|
82
|
+
|
|
83
|
+
// Client reading should now receive EOF (null)
|
|
84
|
+
const first = await input.read();
|
|
85
|
+
assert.strictEqual(first, null);
|
|
86
|
+
|
|
87
|
+
// Subsequent write from the client should reject with a closed pipe error
|
|
88
|
+
await assert.rejects(
|
|
89
|
+
() => input.write(encoder.encode("Is anyone there?")),
|
|
90
|
+
/closed/i,
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await t.test("Data can be written and read sequentially before closing", async () => {
|
|
95
|
+
const { input, output } = createConnNextPair();
|
|
96
|
+
|
|
97
|
+
// Background echo server
|
|
98
|
+
const echoPromise = (async () => {
|
|
99
|
+
while (true) {
|
|
100
|
+
const chunk = await output.read();
|
|
101
|
+
if (chunk === null) break;
|
|
102
|
+
await output.write(chunk);
|
|
103
|
+
}
|
|
104
|
+
})();
|
|
105
|
+
|
|
106
|
+
const encoder = new TextEncoder();
|
|
107
|
+
const decoder = new TextDecoder();
|
|
108
|
+
|
|
109
|
+
// 1. Write & read Chunk 1 sequentially
|
|
110
|
+
await input.write(encoder.encode("Chunk 1"));
|
|
111
|
+
const result1 = await input.read("Chunk 1".length);
|
|
112
|
+
assert.notStrictEqual(result1, null);
|
|
113
|
+
assert.strictEqual(decoder.decode(result1!), "Chunk 1");
|
|
114
|
+
|
|
115
|
+
// 2. Write & read Chunk 2 sequentially
|
|
116
|
+
await input.write(encoder.encode("Chunk 2"));
|
|
117
|
+
const result2 = await input.read("Chunk 2".length);
|
|
118
|
+
assert.notStrictEqual(result2, null);
|
|
119
|
+
assert.strictEqual(decoder.decode(result2!), "Chunk 2");
|
|
120
|
+
|
|
121
|
+
// 3. Close the client side mid-stream
|
|
122
|
+
input.close();
|
|
123
|
+
|
|
124
|
+
// Echo server completes processing gracefully
|
|
125
|
+
await assert.doesNotReject(echoPromise);
|
|
126
|
+
|
|
127
|
+
// 4. Verify that further read returns null (EOF)
|
|
128
|
+
const finalResult = await input.read();
|
|
129
|
+
assert.strictEqual(finalResult, null);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
await t.test("Client detects when the echo server abruptly closes its end", async () => {
|
|
133
|
+
const { input, output } = createConnNextPair();
|
|
134
|
+
const encoder = new TextEncoder();
|
|
135
|
+
|
|
136
|
+
// Run a server loop that can be manually stopped by closing 'output'
|
|
137
|
+
const echoPromise = (async () => {
|
|
138
|
+
while (true) {
|
|
139
|
+
const chunk = await output.read();
|
|
140
|
+
if (chunk === null) break;
|
|
141
|
+
await output.write(chunk);
|
|
142
|
+
}
|
|
143
|
+
})();
|
|
144
|
+
|
|
145
|
+
// --- Simulate Server Shutdown ---
|
|
146
|
+
// The server abruptly closes its end
|
|
147
|
+
output.close();
|
|
148
|
+
await assert.doesNotReject(echoPromise);
|
|
149
|
+
|
|
150
|
+
// Client reading should now receive EOF (null)
|
|
151
|
+
const first = await input.read();
|
|
152
|
+
assert.strictEqual(first, null);
|
|
153
|
+
|
|
154
|
+
// Subsequent write from the client should reject with a closed pipe error
|
|
155
|
+
await assert.rejects(
|
|
156
|
+
() => input.write(encoder.encode("Is anyone there?")),
|
|
157
|
+
/closed/i,
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
await t.test("Repeated close calls are idempotent and do not throw", async () => {
|
|
162
|
+
const { input, output } = createConnNextPair();
|
|
163
|
+
|
|
164
|
+
// Multiple close calls on either side should complete safely without throwing
|
|
165
|
+
assert.doesNotThrow(() => {
|
|
166
|
+
input.close();
|
|
167
|
+
input.close();
|
|
168
|
+
output.close();
|
|
169
|
+
output.close();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const clientRead = await input.read();
|
|
173
|
+
const serverRead = await output.read();
|
|
174
|
+
|
|
175
|
+
assert.strictEqual(clientRead, null);
|
|
176
|
+
assert.strictEqual(serverRead, null);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
}
|
package/dev_utils/mockConn.ts
CHANGED
|
@@ -1,36 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
closed = Promise.resolve(undefined);
|
|
5
|
-
close = () => Promise.resolve();
|
|
6
|
-
abort = () => Promise.resolve();
|
|
7
|
-
ready = Promise.resolve(undefined);
|
|
8
|
-
releaseLock = () => {};
|
|
9
|
-
desiredSize = 20;
|
|
1
|
+
import type { ConnAddr, ConnNext } from "../connNext/connNext.ts";
|
|
2
|
+
import { createAsyncStreamPair } from "./asyncStreamPair.ts";
|
|
3
|
+
import { AsyncStreamConnNext } from "./asyncStreamToNext.ts";
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.pos += chunk.length;
|
|
20
|
-
return Promise.resolve();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function createMockSockConn(
|
|
5
|
+
/**
|
|
6
|
+
* Creates an in-memory mock ConnNext object for unit testing.
|
|
7
|
+
*
|
|
8
|
+
* @param readerBuffs List of Uint8Arrays containing incoming test data
|
|
9
|
+
* @param writerBuf Buffer where outgoing data should be written
|
|
10
|
+
* @param close Optional callback executed on closure
|
|
11
|
+
*/
|
|
12
|
+
export function createMockConn(
|
|
25
13
|
readerBuffs: Uint8Array[],
|
|
26
14
|
writerBuf: Uint8Array,
|
|
27
15
|
close = () => {},
|
|
28
|
-
) {
|
|
29
|
-
|
|
30
|
-
const
|
|
16
|
+
): ConnNext {
|
|
17
|
+
// Maak een async stream pair aan
|
|
18
|
+
const { input, output } = createAsyncStreamPair();
|
|
19
|
+
|
|
20
|
+
const mockAddr: ConnAddr = {
|
|
21
|
+
transport: "tcp",
|
|
22
|
+
hostname: "127.0.0.1",
|
|
23
|
+
port: 1883,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Push all input directly to the input of the StreamPair
|
|
27
|
+
(async () => {
|
|
28
|
+
try {
|
|
29
|
+
for (const buf of readerBuffs) {
|
|
30
|
+
await input.write(buf);
|
|
31
|
+
}
|
|
32
|
+
input.close();
|
|
33
|
+
} catch {
|
|
34
|
+
// ignore errors
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
37
|
+
|
|
38
|
+
// Capture written data and store it in the write buffer
|
|
39
|
+
(async () => {
|
|
40
|
+
try {
|
|
41
|
+
let writerPos = 0;
|
|
42
|
+
for await (const chunk of input.readable) {
|
|
43
|
+
writerBuf.set(chunk, writerPos);
|
|
44
|
+
writerPos += chunk.byteLength;
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
// ignore errors
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
50
|
+
|
|
51
|
+
// Return a ConnNext wrapper connected to the output side
|
|
52
|
+
const wrapper = new AsyncStreamConnNext(output);
|
|
53
|
+
|
|
31
54
|
return {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
55
|
+
remoteAddr: mockAddr,
|
|
56
|
+
localAddr: mockAddr,
|
|
57
|
+
read: (length) => wrapper.read(length),
|
|
58
|
+
write: (data) => wrapper.write(data),
|
|
59
|
+
[Symbol.asyncIterator]: () => wrapper[Symbol.asyncIterator](),
|
|
60
|
+
close: () => {
|
|
61
|
+
wrapper.close();
|
|
62
|
+
output.close();
|
|
63
|
+
close();
|
|
64
|
+
},
|
|
35
65
|
};
|
|
36
66
|
}
|
package/dev_utils/mockServer.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createConnNextPair } from "./asyncStreamPairToNext.ts";
|
|
2
2
|
import { MqttConn } from "../mqttConn/mqttConn.ts";
|
|
3
3
|
import { Context, MqttServer } from "../server/mod.ts";
|
|
4
4
|
import { handlers } from "./test-handlers.ts";
|
|
@@ -11,17 +11,16 @@ export function startMockServer(opts: MqttServerOptions = {}): {
|
|
|
11
11
|
const serverOpts = { handlers, ...opts };
|
|
12
12
|
// start with a fresh clientlist
|
|
13
13
|
Context.clientList.clear();
|
|
14
|
-
// create a new MQTT server
|
|
15
14
|
|
|
16
15
|
const mqttServer = new MqttServer(serverOpts);
|
|
17
|
-
const { input, output } =
|
|
16
|
+
const { input, output } = createConnNextPair();
|
|
18
17
|
const mqttConn = new MqttConn({ conn: output });
|
|
19
18
|
mqttServer.serve(input);
|
|
20
19
|
return { mqttConn, mqttServer };
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
export function addMockClient(mqttServer: MqttServer): MqttConn {
|
|
24
|
-
const { input, output } =
|
|
23
|
+
const { input, output } = createConnNextPair();
|
|
25
24
|
const mqttConn = new MqttConn({ conn: output });
|
|
26
25
|
mqttServer.serve(input);
|
|
27
26
|
return mqttConn;
|
package/dev_utils/mod.ts
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { delay, logger } from "../utils/mod.ts";
|
|
3
|
+
import type { PublishPacket, QoS } from "../mqttPacket/mod.ts";
|
|
4
|
+
import type { Client, ConnectParameters } from "../client/client.ts";
|
|
5
|
+
|
|
6
|
+
export async function testClient(client: Client, params: ConnectParameters) {
|
|
7
|
+
logger.verbose("client parameters: ", params);
|
|
8
|
+
client.onConnected = () =>
|
|
9
|
+
logger.verbose("Client connected to server at:", client.url.toString());
|
|
10
|
+
|
|
11
|
+
await client.connect(params);
|
|
12
|
+
|
|
13
|
+
const publishSet: { topic: string; qos: QoS }[] = [
|
|
14
|
+
{ topic: "t0@q0", qos: 0 },
|
|
15
|
+
{ topic: "t1@q0", qos: 0 },
|
|
16
|
+
{ topic: "t2@q0", qos: 0 },
|
|
17
|
+
{ topic: "t0@q1", qos: 1 },
|
|
18
|
+
{ topic: "t1@q1", qos: 1 },
|
|
19
|
+
{ topic: "t2@q1", qos: 1 },
|
|
20
|
+
{ topic: "t0@q2", qos: 2 },
|
|
21
|
+
{ topic: "t1@q2", qos: 2 },
|
|
22
|
+
{ topic: "t2@q2", qos: 2 },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const subscriptions = publishSet.map((item) => ({
|
|
26
|
+
topicFilter: item.topic,
|
|
27
|
+
qos: item.qos,
|
|
28
|
+
}));
|
|
29
|
+
await client.subscribe({
|
|
30
|
+
subscriptions,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// the IIFE ensures message reception runs in parallel
|
|
34
|
+
logger.verbose("Start receiving");
|
|
35
|
+
const received: PublishPacket[] = [];
|
|
36
|
+
(async () => {
|
|
37
|
+
for await (const item of client.messages()) {
|
|
38
|
+
logger.verbose("Receiving:", item.topic, "--", item.qos);
|
|
39
|
+
received.push(item);
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
// end of IIFE
|
|
43
|
+
for (const item of publishSet) {
|
|
44
|
+
logger.verbose("Publishing:", item.topic, "--", item.qos);
|
|
45
|
+
await client.publish({
|
|
46
|
+
topic: item.topic,
|
|
47
|
+
qos: item.qos,
|
|
48
|
+
payload: new Uint8Array([0x01]),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await delay(100);
|
|
53
|
+
logger.verbose("Disconnect client");
|
|
54
|
+
await client.disconnect();
|
|
55
|
+
|
|
56
|
+
logger.verbose("Check completeness");
|
|
57
|
+
for (const item of publishSet) {
|
|
58
|
+
const found = received.find((f) =>
|
|
59
|
+
f.topic == item.topic && f.qos === item.qos
|
|
60
|
+
);
|
|
61
|
+
logger.verbose("Found:", item.topic, "--", item.qos);
|
|
62
|
+
assert(found, `${item.topic} -- ${item.qos}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
readable: ReadableStream<Uint8Array>;
|
|
3
|
-
writable: WritableStream<Uint8Array>;
|
|
4
|
-
close: () => void;
|
|
5
|
-
}
|
|
1
|
+
import type { WebStreamEndpoint } from "./WebStreamEndpoint.ts";
|
|
6
2
|
|
|
7
3
|
export function createWebStreamPair(): {
|
|
8
|
-
input:
|
|
9
|
-
output:
|
|
4
|
+
input: WebStreamEndpoint;
|
|
5
|
+
output: WebStreamEndpoint;
|
|
10
6
|
} {
|
|
11
7
|
let aController: ReadableStreamDefaultController | null = null;
|
|
12
8
|
let bController: ReadableStreamDefaultController | null = null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ConnAddr, ConnNext } from "../connNext/connNext.ts";
|
|
2
|
+
import { createWebStreamPair } from "./webStreamPair.ts";
|
|
3
|
+
import { webStreamToNext } from "./webStreamToNext.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a pair of cross-connected ConnNext sockets backed by WebStreams.
|
|
7
|
+
*/
|
|
8
|
+
export function createConnNextPair(): {
|
|
9
|
+
input: ConnNext;
|
|
10
|
+
output: ConnNext;
|
|
11
|
+
} {
|
|
12
|
+
const { input: webInput, output: webOutput } = createWebStreamPair();
|
|
13
|
+
|
|
14
|
+
const mockAddr: ConnAddr = {
|
|
15
|
+
transport: "tcp",
|
|
16
|
+
hostname: "127.0.0.1",
|
|
17
|
+
port: 1883,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const inputWrapper = webStreamToNext(webInput);
|
|
21
|
+
const outputWrapper = webStreamToNext(webOutput);
|
|
22
|
+
|
|
23
|
+
const input: ConnNext = {
|
|
24
|
+
remoteAddr: mockAddr,
|
|
25
|
+
localAddr: mockAddr,
|
|
26
|
+
read: (length) => inputWrapper.read(length),
|
|
27
|
+
write: (data) => inputWrapper.write(data),
|
|
28
|
+
[Symbol.asyncIterator]: () => inputWrapper[Symbol.asyncIterator](),
|
|
29
|
+
close: () => {
|
|
30
|
+
inputWrapper.close();
|
|
31
|
+
outputWrapper.close();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const output: ConnNext = {
|
|
36
|
+
remoteAddr: mockAddr,
|
|
37
|
+
localAddr: mockAddr,
|
|
38
|
+
read: (length) => outputWrapper.read(length),
|
|
39
|
+
write: (data) => outputWrapper.write(data),
|
|
40
|
+
[Symbol.asyncIterator]: () => outputWrapper[Symbol.asyncIterator](),
|
|
41
|
+
close: () => {
|
|
42
|
+
outputWrapper.close();
|
|
43
|
+
inputWrapper.close();
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return { input, output };
|
|
48
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseConnNext } from "../connNext/baseConnNext.ts";
|
|
2
|
+
import type { WebStreamEndpoint } from "./WebStreamEndpoint.ts";
|
|
3
|
+
|
|
4
|
+
export class WebStreamConnNext extends BaseConnNext {
|
|
5
|
+
remoteAddr = undefined;
|
|
6
|
+
localAddr = undefined;
|
|
7
|
+
private endPoint;
|
|
8
|
+
private reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
9
|
+
private writer: WritableStreamDefaultWriter<Uint8Array>;
|
|
10
|
+
|
|
11
|
+
constructor(endPoint: WebStreamEndpoint) {
|
|
12
|
+
super();
|
|
13
|
+
this.endPoint = endPoint;
|
|
14
|
+
this.reader = endPoint.readable.getReader();
|
|
15
|
+
this.writer = endPoint.writable.getWriter();
|
|
16
|
+
this.reader.closed.catch(() => {});
|
|
17
|
+
this.writer.closed.catch(() => {});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected async pullNextChunk(): Promise<Uint8Array | null> {
|
|
21
|
+
try {
|
|
22
|
+
const { value, done } = await this.reader.read();
|
|
23
|
+
if (done || !value) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async write(chunk: Uint8Array): Promise<void> {
|
|
33
|
+
if (this.closed) throw new Error("Pipe closed");
|
|
34
|
+
await this.writer.write(chunk);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
close(): void {
|
|
38
|
+
if (!this.closed) {
|
|
39
|
+
this.closed = true;
|
|
40
|
+
try {
|
|
41
|
+
void this.reader.cancel().catch(() => {});
|
|
42
|
+
this.reader.releaseLock();
|
|
43
|
+
} catch { /* swallow */ }
|
|
44
|
+
void this.writer.close().catch(() => {});
|
|
45
|
+
try {
|
|
46
|
+
this.endPoint.close();
|
|
47
|
+
} catch { /* swallow */ }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function webStreamToNext(endPoint: WebStreamEndpoint) {
|
|
53
|
+
return new WebStreamConnNext(endPoint);
|
|
54
|
+
}
|
package/dist/bin/mqtt.js
CHANGED
package/dist/bin/mqtt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mqtt.js","sourceRoot":"","sources":["../../bin/mqtt.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;A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