@@ -6,22 +6,20 @@ import * as testsUtils from './tests/utils';
6
6
import { promise } from './src/utils' ;
7
7
import { SendInfo } from './src/native/types' ;
8
8
import { clearTimeout } from 'timers' ;
9
- import * as events from './src/events' ;
10
9
import QUICConnectionId from './src/QUICConnectionId' ;
11
10
import { Connection } from './src/native/types' ;
12
11
import path from 'path' ;
13
12
14
13
15
14
async function main ( ) {
16
15
const MAX_DATAGRAM_SIZE = 1350 ;
17
- const buf = Buffer . alloc ( 65535 , 0 ) ;
18
16
const out = Buffer . alloc ( quiche . MAX_DATAGRAM_SIZE , 0 ) ;
19
- const message = Buffer . from ( 'Hello!' ) ;
20
17
const emptyBuffer = Buffer . alloc ( 0 , 0 ) ;
21
18
type ConnectionData = {
22
19
conn : Connection ;
23
20
timeout : NodeJS . Timeout | null ;
24
21
deadline : number ;
22
+ streams : Set < number > ;
25
23
}
26
24
const connectionMap : Map < string , ConnectionData > = new Map ( ) ;
27
25
@@ -32,8 +30,6 @@ async function main () {
32
30
33
31
const host = "127.0.0.1" ;
34
32
const localPort = 4433 ;
35
- const STREAMS = 1000 ;
36
- const MESSAGES = 200 ;
37
33
38
34
const socketBind = utils . promisify ( socket . bind ) . bind ( socket ) ;
39
35
const socketClose = utils . promisify ( socket . close ) . bind ( socket ) ;
@@ -90,7 +86,6 @@ async function main () {
90
86
const scidBuffer = new ArrayBuffer ( quiche . MAX_CONN_ID_LEN ) ;
91
87
await crypto . ops . randomBytes ( scidBuffer ) ;
92
88
93
- let req_sent = false ;
94
89
let receivedEvent = promise ( ) ;
95
90
let timeoutEvent = promise ( ) ;
96
91
let writableEvent = promise ( ) ;
@@ -267,6 +262,7 @@ async function main () {
267
262
client = {
268
263
deadline : Infinity ,
269
264
timeout : null ,
265
+ streams : new Set ( ) ,
270
266
conn
271
267
}
272
268
connectionMap . set ( Buffer . from ( scid ) . toString ( ) , client ) ;
@@ -291,10 +287,14 @@ async function main () {
291
287
// Process readable
292
288
for ( const streamId of client . conn . readable ( ) ) {
293
289
// drop data and track finish frame
290
+ client . streams . add ( streamId ) ;
294
291
while ( true ) {
295
292
try {
296
293
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
+ }
298
298
} catch ( e ) {
299
299
if ( e . message === 'Done' ) break ;
300
300
throw e ;
0 commit comments