@@ -42,6 +42,9 @@ export class Http2WebTransportServer {
4242 this . sessionFlowControlWindowSizeLimit =
4343 args ?. sessionFlowControlWindowSizeLimit || 15 * 1024 * 1024
4444
45+ this . initialDatagramSize =
46+ args . initialDatagramSize || this . streamFlowControlWindowSizeLimit - 128
47+
4548 /** @type {Record<string, boolean> } */
4649 this . paths = { }
4750 this . hasrequesthandler = false
@@ -64,10 +67,13 @@ export class Http2WebTransportServer {
6467 0x2b62 : this . initialStreamFlowControlWindow , // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAM_DATA_UNI
6568 0x2b63 : this . initialStreamFlowControlWindow , // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAM_DATA_BIDI
6669 0x2b64 : this . initialUnidirectionalStreams , // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_UNI
67- 0x2b65 : this . initialBidirectionalStreams // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_BIDI
70+ 0x2b65 : this . initialBidirectionalStreams , // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_BIDI
71+ 0x2b66 : this . initialDatagramSize // SETTINGS_MAX_DATAGRAM_SIZE
6872 }
6973 } ,
70- remoteCustomSettings : [ 0x2b60 , 0x2b61 , 0x2b62 , 0x2b63 , 0x2b64 , 0x2b65 ]
74+ remoteCustomSettings : [
75+ 0x2b60 , 0x2b61 , 0x2b62 , 0x2b63 , 0x2b64 , 0x2b65 , 0x2b66
76+ ]
7177 } )
7278
7379 this . serverInt . on ( 'listening' , ( ) => {
@@ -179,7 +185,9 @@ export class Http2WebTransportServer {
179185 streamShouldAutoTuneReceiveWindow :
180186 this . streamShouldAutoTuneReceiveWindow ,
181187 streamReceiveWindowSizeLimit :
182- this . streamFlowControlWindowSizeLimit
188+ this . streamFlowControlWindowSizeLimit ,
189+ maxDatagramSize : this . initialDatagramSize ,
190+ remoteMaxDatagramSize : 2 ** 62 - 1 // we wait for the settings frame to be received
183191 } ) )
184192 if ( head . byteLength > 0 ) parse . parseData ( head )
185193 return parse
@@ -272,7 +280,8 @@ export class Http2WebTransportServer {
272280 0x2b64 : remoteUnidirectionalStreams = undefined ,
273281 0x2b63 : remoteBidirectionalStreamFlowControlWindow = undefined ,
274282 0x2b62 : remoteUnidirectionalStreamFlowControlWindow = undefined ,
275- 0x2b61 : remoteSessionFlowControlWindow = undefined
283+ 0x2b61 : remoteSessionFlowControlWindow = undefined ,
284+ 0x2b66 : remoteMaxDatagramSize = 2 ** 62 - 1 // note this exceeds safe integer
276285 // @ts -ignore
277286 } = stream ?. session ?. remoteSettings ?. customSettings || { }
278287 const retObj = {
@@ -298,7 +307,9 @@ export class Http2WebTransportServer {
298307 streamShouldAutoTuneReceiveWindow :
299308 this . streamShouldAutoTuneReceiveWindow ,
300309 streamReceiveWindowSizeLimit :
301- this . streamFlowControlWindowSizeLimit
310+ this . streamFlowControlWindowSizeLimit ,
311+ maxDatagramSize : this . initialDatagramSize ,
312+ remoteMaxDatagramSize
302313 } )
303314 } else {
304315 return ( this . capsParser = new WebSocketParser ( {
@@ -312,7 +323,9 @@ export class Http2WebTransportServer {
312323 streamShouldAutoTuneReceiveWindow :
313324 this . streamShouldAutoTuneReceiveWindow ,
314325 streamReceiveWindowSizeLimit :
315- this . streamFlowControlWindowSizeLimit
326+ this . streamFlowControlWindowSizeLimit ,
327+ maxDatagramSize : this . initialDatagramSize ,
328+ remoteMaxDatagramSize
316329 } ) )
317330 }
318331 } ,
@@ -515,7 +528,9 @@ export class Http2WebTransportServer {
515528 streamShouldAutoTuneReceiveWindow :
516529 this . streamShouldAutoTuneReceiveWindow ,
517530 streamReceiveWindowSizeLimit :
518- this . streamFlowControlWindowSizeLimit
531+ this . streamFlowControlWindowSizeLimit ,
532+ maxDatagramSize : this . initialDatagramSize ,
533+ remoteMaxDatagramSize : 2 ** 62 - 1 // we wait for the frame
519534 } ) )
520535 if ( head && head . byteLength > 0 ) parse . parseData ( head )
521536 return parse
@@ -562,7 +577,8 @@ export class Http2WebTransportServer {
562577 0x2b64 : remoteUnidirectionalStreams = undefined ,
563578 0x2b63 : remoteBidirectionalStreamFlowControlWindow = undefined ,
564579 0x2b62 : remoteUnidirectionalStreamFlowControlWindow = undefined ,
565- 0x2b61 : remoteSessionFlowControlWindow = undefined
580+ 0x2b61 : remoteSessionFlowControlWindow = undefined ,
581+ 0x2b66 : remoteMaxDatagramSize = 2 ** 62 - 1 // note this exceeds safe integer
566582 // @ts -ignore
567583 } = stream ?. session ?. remoteSettings ?. customSettings || { }
568584 const retObj = {
@@ -588,7 +604,9 @@ export class Http2WebTransportServer {
588604 streamShouldAutoTuneReceiveWindow :
589605 this . streamShouldAutoTuneReceiveWindow ,
590606 streamReceiveWindowSizeLimit :
591- this . streamFlowControlWindowSizeLimit
607+ this . streamFlowControlWindowSizeLimit ,
608+ maxDatagramSize : this . initialDatagramSize ,
609+ remoteMaxDatagramSize
592610 } )
593611 } else {
594612 return ( this . capsParser = new WebSocketParser ( {
@@ -602,7 +620,9 @@ export class Http2WebTransportServer {
602620 streamShouldAutoTuneReceiveWindow :
603621 this . streamShouldAutoTuneReceiveWindow ,
604622 streamReceiveWindowSizeLimit :
605- this . streamFlowControlWindowSizeLimit
623+ this . streamFlowControlWindowSizeLimit ,
624+ maxDatagramSize : this . initialDatagramSize ,
625+ remoteMaxDatagramSize
606626 } ) )
607627 }
608628 } ,
0 commit comments