Skip to content

Commit dfe4715

Browse files
committed
wip: tracking streams
* Related #20 [ci skip]
1 parent a244e59 commit dfe4715

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

serverTest.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ import * as testsUtils from './tests/utils';
66
import { promise } from './src/utils';
77
import { SendInfo } from './src/native/types';
88
import { clearTimeout } from 'timers';
9-
import * as events from './src/events';
109
import QUICConnectionId from './src/QUICConnectionId';
1110
import { Connection } from './src/native/types';
1211
import path from 'path';
1312

1413

1514
async function main () {
1615
const MAX_DATAGRAM_SIZE = 1350;
17-
const buf = Buffer.alloc(65535, 0);
1816
const out = Buffer.alloc(quiche.MAX_DATAGRAM_SIZE, 0);
19-
const message = Buffer.from('Hello!');
2017
const emptyBuffer = Buffer.alloc(0, 0);
2118
type ConnectionData = {
2219
conn: Connection;
2320
timeout: NodeJS.Timeout | null;
2421
deadline: number;
22+
streams: Set<number>;
2523
}
2624
const connectionMap: Map<string, ConnectionData> = new Map();
2725

@@ -32,8 +30,6 @@ async function main () {
3230

3331
const host = "127.0.0.1";
3432
const localPort = 4433;
35-
const STREAMS = 1000;
36-
const MESSAGES = 200;
3733

3834
const socketBind = utils.promisify(socket.bind).bind(socket);
3935
const socketClose = utils.promisify(socket.close).bind(socket);
@@ -90,7 +86,6 @@ async function main () {
9086
const scidBuffer = new ArrayBuffer(quiche.MAX_CONN_ID_LEN);
9187
await crypto.ops.randomBytes(scidBuffer);
9288

93-
let req_sent = false;
9489
let receivedEvent = promise();
9590
let timeoutEvent = promise();
9691
let writableEvent = promise();
@@ -267,6 +262,7 @@ async function main () {
267262
client = {
268263
deadline: Infinity,
269264
timeout: null,
265+
streams: new Set(),
270266
conn
271267
}
272268
connectionMap.set(Buffer.from(scid).toString(), client);
@@ -291,10 +287,14 @@ async function main () {
291287
// Process readable
292288
for (const streamId of client.conn.readable()) {
293289
// drop data and track finish frame
290+
client.streams.add(streamId);
294291
while (true) {
295292
try {
296293
const [, fin] = client.conn.streamRecv(streamId, data);
297-
if (fin) console.log("Stream finished! ", streamId);
294+
if (fin) {
295+
client.streams.delete(streamId)
296+
console.log("Stream finished! ", streamId, "left", client.streams.size);
297+
}
298298
} catch (e) {
299299
if (e.message === 'Done') break;
300300
throw e;

0 commit comments

Comments
 (0)