@fails-components/webtransport 0.1.5 → 0.2.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/CMakeLists.txt +42 -111
- package/build.js +4 -4
- package/dist/lib/dom.d.ts +6 -0
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/lib/event-loop.d.ts +8 -3
- package/dist/lib/event-loop.d.ts.map +1 -1
- package/dist/lib/server.d.ts +3 -2
- package/dist/lib/server.d.ts.map +1 -1
- package/dist/lib/session.d.ts +78 -18
- package/dist/lib/session.d.ts.map +1 -1
- package/dist/lib/stream.d.ts +13 -5
- package/dist/lib/stream.d.ts.map +1 -1
- package/dist/lib/transport.d.ts.map +1 -1
- package/dist/lib/types.d.ts +11 -2
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/webtransport.d.ts +22 -0
- package/dist/lib/webtransport.d.ts.map +1 -1
- package/dist/test/bidirectional-streams.spec.d.ts.map +1 -1
- package/dist/test/datagrams.spec.d.ts.map +1 -1
- package/dist/test/fixtures/p-timeout.d.ts +8 -0
- package/dist/test/fixtures/p-timeout.d.ts.map +1 -0
- package/dist/test/fixtures/read-stream.d.ts.map +1 -1
- package/dist/test/unidirectional-streams.spec.d.ts.map +1 -1
- package/lib/dom.ts +7 -2
- package/lib/event-loop.js +13 -7
- package/lib/server.js +1 -1
- package/lib/session.js +71 -21
- package/lib/stream.js +137 -12
- package/lib/transport.js +3 -1
- package/lib/types.ts +13 -2
- package/lib/webtransport.js +31 -0
- package/package.json +5 -4
- package/platform/base/strings/utf_ostream_operators.h +5 -0
- package/platform/quiche/quic/core/io/socket_win.inc +3 -0
- package/platform/quiche_platform_impl/quiche_command_line_flags_impl.h +7 -0
- package/platform/quiche_platform_impl/quiche_export_impl.h +3 -9
- package/platform/quiche_platform_impl/quiche_server_stats_impl.h +1 -22
- package/platform/quiche_platform_impl/quiche_stream_buffer_allocator_impl.h +1 -4
- package/platform/quiche_platform_impl/quiche_time_utils_impl.h +1 -13
- package/platform/quiche_platform_impl/quiche_udp_socket_platform_impl.h +9 -0
- package/readme.md +3 -1
- package/src/http3client.cc +13 -29
- package/src/http3client.h +2 -6
- package/src/http3clientsession.cc +51 -40
- package/src/http3clientsession.h +44 -31
- package/src/http3clientstream.cc +17 -0
- package/src/http3clientstream.h +10 -0
- package/src/http3eventloop.cc +81 -61
- package/src/http3eventloop.h +10 -7
- package/src/http3server.cc +1 -1
- package/src/http3serversession.cc +1 -136
- package/src/http3serversession.h +7 -77
- package/src/http3serverstream.cc +0 -49
- package/src/http3serverstream.h +0 -5
- package/src/http3wtsessionvisitor.cc +1 -1
- package/src/http3wtsessionvisitor.h +24 -37
- package/src/http3wtstreamvisitor.cc +35 -8
- package/src/http3wtstreamvisitor.h +81 -3
- package/test/bidirectional-streams.spec.js +16 -7
- package/test/datagrams.spec.js +31 -20
- package/test/fixtures/p-timeout.js +33 -0
- package/test/fixtures/read-stream.js +4 -1
- package/test/unidirectional-streams.spec.js +24 -15
- package/platform/net/quiche/common/platform/impl/quiche_flags_impl.h +0 -12
- package/platform/poll.h +0 -2
- package/platform/quiche/quic/core/io/quic_poll_event_loop.h +0 -8
- package/platform/quiche_platform_impl/quic_testvalue_impl.h +0 -19
- package/platform/quiche_platform_impl/quic_udp_socket_winsock.cc +0 -732
- package/platform/quiche_platform_impl/quiche_time_utils_impl.cc +0 -43
- package/platform/quiche_platform_impl/socket_winsock.cc +0 -535
package/dist/lib/stream.d.ts
CHANGED
|
@@ -43,13 +43,23 @@ export class Http3WTStream {
|
|
|
43
43
|
/** @type {Promise<void> | null} */
|
|
44
44
|
pendingoperation: Promise<void> | null;
|
|
45
45
|
pendingres: (() => void) | null;
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
/** @type {Promise<void> | null} */
|
|
47
|
+
pendingoperationRead: Promise<void> | null;
|
|
48
|
+
pendingresRead: ((value: void | PromiseLike<void>) => void) | null;
|
|
49
|
+
/** @type {Number} */
|
|
50
|
+
incomingbufferfilled: number;
|
|
51
|
+
/** @type {Number} */
|
|
52
|
+
incomingbufferreadpos: number;
|
|
53
|
+
/** @type {WebTransportReceiveStream} */
|
|
54
|
+
readable: WebTransportReceiveStream;
|
|
55
|
+
readableController: import("stream/web").ReadableByteStreamController;
|
|
48
56
|
cancelres: (() => void) | null;
|
|
49
57
|
readableclosed: boolean;
|
|
50
|
-
|
|
58
|
+
/** @type {WebTransportSendStream} */
|
|
59
|
+
writable: WebTransportSendStream;
|
|
51
60
|
writableController: import("stream/web").WritableStreamDefaultController;
|
|
52
61
|
abortres: (() => void) | null;
|
|
62
|
+
drainBuffer(): void;
|
|
53
63
|
/**
|
|
54
64
|
* @param {import('./types').StreamRecvSignalEvent} args
|
|
55
65
|
* @returns {void}
|
|
@@ -111,6 +121,4 @@ export type Http3WTSession = import('./session').Http3WTSession;
|
|
|
111
121
|
* WebTransport stream events
|
|
112
122
|
*/
|
|
113
123
|
export type WritableStreamDefaultController = import('stream/web').WritableStreamDefaultController;
|
|
114
|
-
import { ReadableStream } from "stream/web";
|
|
115
|
-
import { WritableStream } from "stream/web";
|
|
116
124
|
//# sourceMappingURL=stream.d.ts.map
|
package/dist/lib/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../lib/stream.js"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG;AAEH;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../lib/stream.js"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG;AAEH;IA6YE;;OAEG;IACH,sBAFW,qBAAqB,GAAG,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,wBAAwB,QAsClH;IAnbD;;;;;;;OAOG;IACH;QANqC,MAAM,EAAhC,mBAAmB;QACE,SAAS,EAA9B,cAAc;QACD,SAAS,EAAtB,MAAM;QACQ,aAAa,EAA3B,OAAO;QACO,QAAQ,EAAtB,OA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"mappings":"AAGA;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../lib/transport.js"],"names":[],"mappings":"AAGA;IAoBE;;;;;;OAMG;IACH;;;uCALgD,GAAG,KAAK,IAAI;;;iBAC9C,MAAM;aAgBnB;IAtCD;;;OAGG;IACH,gCAFW,QAAQ,GAAG,QAAQ,EAe7B;IAPG,kBAAyE;IAM3E,aAAkB;CAuBrB"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface NativeHttp3WTSession {
|
|
|
7
7
|
writeDatagram: (chunk: Uint8Array) => void;
|
|
8
8
|
orderUnidiStream: () => void;
|
|
9
9
|
orderBidiStream: () => void;
|
|
10
|
+
notifySessionDraining(): () => void;
|
|
10
11
|
close: (arg: {
|
|
11
12
|
code: number;
|
|
12
13
|
reason: string;
|
|
@@ -16,7 +17,9 @@ export interface NativeHttp3WTSession {
|
|
|
16
17
|
* Native Http3WTStream counterpart
|
|
17
18
|
*/
|
|
18
19
|
export interface NativeHttp3WTStream {
|
|
20
|
+
updateReadPos(bytesread: Number, pos: Number): unknown;
|
|
19
21
|
jsobj: WebTransportStreamEventHandler;
|
|
22
|
+
readbuffer: Uint8Array | undefined;
|
|
20
23
|
startReading: () => void;
|
|
21
24
|
stopReading: () => void;
|
|
22
25
|
stopSending: (code: number) => void;
|
|
@@ -35,8 +38,9 @@ export interface StreamRecvSignalEvent {
|
|
|
35
38
|
export interface StreamReadEvent {
|
|
36
39
|
object: NativeHttp3WTStream;
|
|
37
40
|
purpose: 'StreamRead';
|
|
38
|
-
|
|
41
|
+
buffergrow?: number;
|
|
39
42
|
fin?: boolean;
|
|
43
|
+
success?: boolean;
|
|
40
44
|
}
|
|
41
45
|
export interface StreamWriteEvent {
|
|
42
46
|
object: NativeHttp3WTStream;
|
|
@@ -77,6 +81,10 @@ export interface DatagramSendEvent {
|
|
|
77
81
|
object: NativeHttp3WTSession;
|
|
78
82
|
purpose: 'DatagramSend';
|
|
79
83
|
}
|
|
84
|
+
export interface GoawayReceivedEvent {
|
|
85
|
+
object: NativeHttp3WTSession;
|
|
86
|
+
purpose: 'GoawayReceived';
|
|
87
|
+
}
|
|
80
88
|
export interface NewStreamEvent {
|
|
81
89
|
object: NativeHttp3WTSession;
|
|
82
90
|
purpose: 'Http3WTStreamVisitor';
|
|
@@ -90,6 +98,7 @@ export interface WebTransportSessionEventHandler {
|
|
|
90
98
|
onClose: (evt: SessionCloseEvent) => void;
|
|
91
99
|
onDatagramReceived: (evt: DatagramReceivedEvent) => void;
|
|
92
100
|
onDatagramSend: (evt: DatagramSendEvent) => void;
|
|
101
|
+
onGoAwayReceived: (evt: GoawayReceivedEvent) => void;
|
|
93
102
|
onStream: (evt: NewStreamEvent) => void;
|
|
94
103
|
closeHook?: (() => void) | null;
|
|
95
104
|
}
|
|
@@ -150,7 +159,7 @@ export interface Deferred<T = unknown> {
|
|
|
150
159
|
resolve: (value?: T) => void;
|
|
151
160
|
reject: (reason?: any) => void;
|
|
152
161
|
}
|
|
153
|
-
export declare type WebTransportSessionState = 'connected' | 'closed' | 'failed';
|
|
162
|
+
export declare type WebTransportSessionState = 'connected' | 'draining' | 'closed' | 'failed';
|
|
154
163
|
export interface WebTransportSession extends WebTransport {
|
|
155
164
|
state: WebTransportSessionState;
|
|
156
165
|
}
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEzC;;GAEG;AACF,MAAM,WAAW,oBAAoB;IACpC,KAAK,EAAE,+BAA+B,CAAA;IACtC,aAAa,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IAC1C,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,eAAe,EAAE,MAAM,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"types.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CAAA;IAC5B,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;CAC/B;AAED,oBAAY,wBAAwB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAErF,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,KAAK,EAAE,wBAAwB,CAAA;CAChC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB"}
|
|
@@ -16,11 +16,33 @@ export class WebTransport implements WebTransportInterface {
|
|
|
16
16
|
constructor(url: string, args?: import("./dom").WebTransportOptions | undefined);
|
|
17
17
|
ready: Promise<void>;
|
|
18
18
|
closed: Promise<import("./dom").WebTransportCloseInfo>;
|
|
19
|
+
draining: Promise<undefined>;
|
|
19
20
|
datagrams: import("./dom").WebTransportDatagramDuplexStream;
|
|
20
21
|
/** @type {ReadableStream<WebTransportBidirectionalStream>} */
|
|
21
22
|
incomingBidirectionalStreams: ReadableStream<WebTransportBidirectionalStream>;
|
|
22
23
|
/** @type {ReadableStream<WebTransportReceiveStream>} */
|
|
23
24
|
incomingUnidirectionalStreams: ReadableStream<WebTransportReceiveStream>;
|
|
25
|
+
get reliability(): import("./dom").WebTransportReliabilityMode;
|
|
26
|
+
get congestionControl(): import("./dom").WebTransportCongestionControl;
|
|
27
|
+
getStats(): Promise<{
|
|
28
|
+
timestamp: number;
|
|
29
|
+
bytesSent: bigint;
|
|
30
|
+
packetsSent: bigint;
|
|
31
|
+
packetsLost: bigint;
|
|
32
|
+
numOutgoingStreamsCreated: number;
|
|
33
|
+
numIncomingStreamsCreated: number;
|
|
34
|
+
bytesReceived: bigint;
|
|
35
|
+
packetsReceived: bigint;
|
|
36
|
+
smoothedRtt: number;
|
|
37
|
+
rttVariation: number;
|
|
38
|
+
minRtt: number;
|
|
39
|
+
datagrams: {
|
|
40
|
+
timestamp: number;
|
|
41
|
+
expiredOutgoing: bigint;
|
|
42
|
+
droppedIncoming: bigint;
|
|
43
|
+
lostOutgoing: bigint;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
24
46
|
/**
|
|
25
47
|
* @param {WebTransportCloseInfo} [closeinfo]
|
|
26
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webtransport.d.ts","sourceRoot":"","sources":["../../lib/webtransport.js"],"names":[],"mappings":"AAMA;;;;GAIG;AAEH;;;;GAIG;AACH;IACE;;;OAGG;IACH,iBAHW,MAAM,
|
|
1
|
+
{"version":3,"file":"webtransport.d.ts","sourceRoot":"","sources":["../../lib/webtransport.js"],"names":[],"mappings":"AAMA;;;;GAIG;AAEH;;;;GAIG;AACH;IACE;;;OAGG;IACH,iBAHW,MAAM,0DA0DhB;IAnCC,qBAA6B;IAC7B,uDAA+B;IAC/B,6BAAmC;IAEnC,4DAAqC;IAErC,8DAA8D;IAC9D,8BADW,eAAe,+BAA+B,CAAC,CACiB;IAE3E,wDAAwD;IACxD,+BADW,eAAe,yBAAyB,CAAC,CAEV;IA0B5C,+DAQC;IAED,uEAQC;IAED;;;;;;;;;;;;;;;;;;OAQC;IAED;;OAEG;IACH,2EASC;IAED,sFASC;IAED,8EASC;CACF;oCAzIY,OAAO,OAAO,EAAE,qBAAqB;8CACrC,OAAO,OAAO,EAAE,+BAA+B;wCAC/C,OAAO,OAAO,EAAE,yBAAyB;oCAIzC,OAAO,OAAO,EAAE,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bidirectional-streams.spec.d.ts","sourceRoot":"","sources":["../../test/bidirectional-streams.spec.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"bidirectional-streams.spec.d.ts","sourceRoot":"","sources":["../../test/bidirectional-streams.spec.js"],"names":[],"mappings":";;;0BAaa,OAAO,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datagrams.spec.d.ts","sourceRoot":"","sources":["../../test/datagrams.spec.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"datagrams.spec.d.ts","sourceRoot":"","sources":["../../test/datagrams.spec.js"],"names":[],"mappings":";;;0BAaa,OAAO,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"p-timeout.d.ts","sourceRoot":"","sources":["../../../test/fixtures/p-timeout.js"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,0DAHW,MAAM,cAkBhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-stream.d.ts","sourceRoot":"","sources":["../../../test/fixtures/read-stream.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,
|
|
1
|
+
{"version":3,"file":"read-stream.d.ts","sourceRoot":"","sources":["../../../test/fixtures/read-stream.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wGA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unidirectional-streams.spec.d.ts","sourceRoot":"","sources":["../../test/unidirectional-streams.spec.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"unidirectional-streams.spec.d.ts","sourceRoot":"","sources":["../../test/unidirectional-streams.spec.js"],"names":[],"mappings":";;;0BAaa,OAAO,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
package/lib/dom.ts
CHANGED
|
@@ -73,13 +73,16 @@ export interface WebTransportOptions {
|
|
|
73
73
|
allowPooling?: boolean
|
|
74
74
|
requireUnreliable?: boolean
|
|
75
75
|
serverCertificateHashes?: WebTransportHash[]
|
|
76
|
+
congestionControl?: WebTransportCongestionControl
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
export interface WebTransport {
|
|
79
|
-
|
|
80
|
+
getStats: () => Promise<WebTransportStats>
|
|
80
81
|
readonly ready: Promise<void>
|
|
81
|
-
|
|
82
|
+
readonly reliability: WebTransportReliabilityMode
|
|
83
|
+
readonly congestionControl: WebTransportCongestionControl
|
|
82
84
|
readonly closed: Promise<WebTransportCloseInfo>
|
|
85
|
+
readonly draining: Promise<undefined>
|
|
83
86
|
close: (closeInfo?: WebTransportCloseInfo) => void
|
|
84
87
|
readonly datagrams: WebTransportDatagramDuplexStream
|
|
85
88
|
|
|
@@ -93,3 +96,5 @@ export interface WebTransport {
|
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
export type WebTransportReliabilityMode = 'pending' | 'reliable-only' | 'supports-unreliable'
|
|
99
|
+
export type WebTransportCongestionControl = 'default' | 'throughput' | 'low-latency';
|
|
100
|
+
|
package/lib/event-loop.js
CHANGED
|
@@ -15,7 +15,8 @@ export class Http3EventLoop {
|
|
|
15
15
|
transportCallback: Http3WebTransport.transportCallback,
|
|
16
16
|
streamCallback: Http3WTStream.callback,
|
|
17
17
|
sessionCallback: Http3WTSession.callback,
|
|
18
|
-
eventloopCallback: Http3EventLoop.callback
|
|
18
|
+
eventloopCallback: Http3EventLoop.callback,
|
|
19
|
+
quicheLogVerbose: args?.quicheLogVerbose
|
|
19
20
|
})
|
|
20
21
|
this.eventloopInt.jsobj = this
|
|
21
22
|
|
|
@@ -23,9 +24,12 @@ export class Http3EventLoop {
|
|
|
23
24
|
this.loopGuardian = this.loopGuardian.bind(this)
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @param {*} [args]
|
|
29
|
+
*/
|
|
30
|
+
startEventLoop(args) {
|
|
27
31
|
console.log('start GlobalEventLoop')
|
|
28
|
-
this.eventloopInt.startEventLoop()
|
|
32
|
+
this.eventloopInt.startEventLoop(args)
|
|
29
33
|
this.loopGuardianTimer = setInterval(this.loopGuardian, 5000)
|
|
30
34
|
}
|
|
31
35
|
|
|
@@ -54,12 +58,13 @@ export class Http3EventLoop {
|
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
/**
|
|
61
|
+
* @param {any} [args]
|
|
57
62
|
* @returns {Http3EventLoop}
|
|
58
63
|
*/
|
|
59
|
-
static createGlobalEventLoop() {
|
|
64
|
+
static createGlobalEventLoop(args) {
|
|
60
65
|
if (!Http3EventLoop.globalLoop) {
|
|
61
66
|
Http3EventLoop.globalLoop = new Http3EventLoop()
|
|
62
|
-
Http3EventLoop.globalLoop.startEventLoop()
|
|
67
|
+
Http3EventLoop.globalLoop.startEventLoop(args)
|
|
63
68
|
console.log('createGlobalEventLoop')
|
|
64
69
|
}
|
|
65
70
|
return Http3EventLoop.globalLoop
|
|
@@ -67,12 +72,13 @@ export class Http3EventLoop {
|
|
|
67
72
|
|
|
68
73
|
/**
|
|
69
74
|
* @param {any} object
|
|
75
|
+
* @param {any} args
|
|
70
76
|
* @returns {Http3EventLoop}
|
|
71
77
|
*/
|
|
72
|
-
static getGlobalEventLoop(object) {
|
|
78
|
+
static getGlobalEventLoop(object, args) {
|
|
73
79
|
if (!object) throw new Error('getGlobalEventLoop without reference object')
|
|
74
80
|
const loop =
|
|
75
|
-
Http3EventLoop.globalLoop ?? Http3EventLoop.createGlobalEventLoop()
|
|
81
|
+
Http3EventLoop.globalLoop ?? Http3EventLoop.createGlobalEventLoop(args)
|
|
76
82
|
loop.refObjects.add(new WeakRef(object))
|
|
77
83
|
return loop
|
|
78
84
|
}
|
package/lib/server.js
CHANGED
|
@@ -29,7 +29,7 @@ export class Http3Server extends Http3WebTransport {
|
|
|
29
29
|
/** @type {Record<string, ReadableStream>} */
|
|
30
30
|
this.sessionStreams = {}
|
|
31
31
|
|
|
32
|
-
/** @type {Record<string,
|
|
32
|
+
/** @type {Record<string, ReadableStreamDefaultController<Http3WTSession>>} */
|
|
33
33
|
this.sessionController = {}
|
|
34
34
|
|
|
35
35
|
this.port = null
|
package/lib/session.js
CHANGED
|
@@ -8,12 +8,17 @@ import { Http3WTStream } from './stream.js'
|
|
|
8
8
|
* @typedef {import('./types').SessionCloseEvent} SessionCloseEvent
|
|
9
9
|
* @typedef {import('./types').DatagramReceivedEvent} DatagramReceivedEvent
|
|
10
10
|
* @typedef {import('./types').DatagramSendEvent} DatagramSendEvent
|
|
11
|
+
* @typedef {import('./types').GoawayReceivedEvent} GoawayReceivedEvent
|
|
11
12
|
* @typedef {import('./types').NewStreamEvent} NewStreamEvent
|
|
12
13
|
*
|
|
13
14
|
* @typedef {import('./dom').WebTransportCloseInfo} WebTransportCloseInfo
|
|
14
15
|
* @typedef {import('./dom').WebTransportBidirectionalStream} WebTransportBidirectionalStream
|
|
15
16
|
* @typedef {import('./dom').WebTransportSendStream} WebTransportSendStream
|
|
17
|
+
* @typedef {import('./dom').WebTransportReceiveStream} WebTransportReceiveStream
|
|
16
18
|
* @typedef {import('./dom').WebTransportDatagramDuplexStream} WebTransportDatagramDuplexStream
|
|
19
|
+
* @typedef {import('./dom').WebTransportReliabilityMode} WebTransportReliabilityMode
|
|
20
|
+
* @typedef {import('./dom').WebTransportCongestionControl} WebTransportCongestionControl
|
|
21
|
+
* @typedef {import('./dom').WebTransportStats} WebTransportStats
|
|
17
22
|
*
|
|
18
23
|
* @typedef {import('./types').NativeHttp3WTSession} NativeHttp3WTSession
|
|
19
24
|
*
|
|
@@ -58,19 +63,32 @@ export class Http3WTSession {
|
|
|
58
63
|
this.readyResolve = resolve
|
|
59
64
|
this.readyReject = reject
|
|
60
65
|
})
|
|
66
|
+
/** @type {WebTransportReliabilityMode} */
|
|
67
|
+
this.reliability = 'pending'
|
|
68
|
+
/** @type {WebTransportCongestionControl} */
|
|
69
|
+
this.congestionControl = 'default'
|
|
61
70
|
/** @type {Promise<WebTransportCloseInfo>} */
|
|
62
71
|
this.closed = new Promise((resolve, reject) => {
|
|
63
72
|
this.closedResolve = resolve
|
|
64
73
|
this.closedReject = reject
|
|
65
74
|
})
|
|
66
75
|
|
|
76
|
+
/** @type {Promise<undefined>} */
|
|
77
|
+
this.draining = new Promise((resolve, reject) => {
|
|
78
|
+
this.drainingResolve = resolve
|
|
79
|
+
this.drainingReject = reject
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
/** @type {ReadableStream<WebTransportBidirectionalStream>} */
|
|
67
83
|
this.incomingBidirectionalStreams = new ReadableStream({
|
|
84
|
+
/** @param {ReadableStreamDefaultController<WebTransportBidirectionalStream>} controller */
|
|
68
85
|
start: (controller) => {
|
|
69
86
|
this.incomBiDiController = controller
|
|
70
87
|
}
|
|
71
88
|
})
|
|
72
|
-
|
|
89
|
+
/** @type {ReadableStream<WebTransportReceiveStream>} */
|
|
73
90
|
this.incomingUnidirectionalStreams = new ReadableStream({
|
|
91
|
+
/** @param {ReadableStreamDefaultController<WebTransportReceiveStream>} controller */
|
|
74
92
|
start: (controller) => {
|
|
75
93
|
this.incomUniDiController = controller
|
|
76
94
|
}
|
|
@@ -86,7 +104,9 @@ export class Http3WTSession {
|
|
|
86
104
|
/** @type {WebTransportDatagramDuplexStream} */
|
|
87
105
|
this.datagrams = {
|
|
88
106
|
readable: new ReadableStream({
|
|
89
|
-
start: (
|
|
107
|
+
start: (
|
|
108
|
+
/** @type {ReadableStreamDefaultController<Uint8Array>} */ controller
|
|
109
|
+
) => {
|
|
90
110
|
this.incomDatagramController = controller
|
|
91
111
|
}
|
|
92
112
|
}),
|
|
@@ -126,7 +146,9 @@ export class Http3WTSession {
|
|
|
126
146
|
/** @type {Array<(err?: Error) => void>} */
|
|
127
147
|
this.rejectUniDi = []
|
|
128
148
|
|
|
149
|
+
/** @type {Set<WebTransportSendStream>} */
|
|
129
150
|
this.sendStreams = new Set()
|
|
151
|
+
/** @type {Set<WebTransportReceiveStream>} */
|
|
130
152
|
this.receiveStreams = new Set()
|
|
131
153
|
/** @type {Set<Http3WTStream>} */
|
|
132
154
|
this.streamObjs = new Set()
|
|
@@ -147,6 +169,28 @@ export class Http3WTSession {
|
|
|
147
169
|
}
|
|
148
170
|
}
|
|
149
171
|
|
|
172
|
+
getStats() {
|
|
173
|
+
return Promise.resolve({
|
|
174
|
+
timestamp: Date.now(),
|
|
175
|
+
bytesSent: BigInt(0),
|
|
176
|
+
packetsSent: BigInt(0),
|
|
177
|
+
packetsLost: BigInt(0),
|
|
178
|
+
numOutgoingStreamsCreated: 0,
|
|
179
|
+
numIncomingStreamsCreated: 0,
|
|
180
|
+
bytesReceived: BigInt(0),
|
|
181
|
+
packetsReceived: BigInt(0),
|
|
182
|
+
smoothedRtt: 0,
|
|
183
|
+
rttVariation: 0,
|
|
184
|
+
minRtt: 0,
|
|
185
|
+
datagrams: {
|
|
186
|
+
timestamp: Date.now(),
|
|
187
|
+
expiredOutgoing: BigInt(0),
|
|
188
|
+
droppedIncoming: BigInt(0),
|
|
189
|
+
lostOutgoing: BigInt(0)
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
|
|
150
194
|
async waitForDatagramsSend() {
|
|
151
195
|
while (this.writeDatagramProm.length > 0) {
|
|
152
196
|
try {
|
|
@@ -157,6 +201,13 @@ export class Http3WTSession {
|
|
|
157
201
|
}
|
|
158
202
|
}
|
|
159
203
|
|
|
204
|
+
notifySessionDraining() {
|
|
205
|
+
if (this.objint == null) {
|
|
206
|
+
throw new Error('this.objint not set')
|
|
207
|
+
}
|
|
208
|
+
this.objint.notifySessionDraining()
|
|
209
|
+
}
|
|
210
|
+
|
|
160
211
|
/**
|
|
161
212
|
* @param {Http3WTStream} stream
|
|
162
213
|
*/
|
|
@@ -172,7 +223,7 @@ export class Http3WTSession {
|
|
|
172
223
|
}
|
|
173
224
|
|
|
174
225
|
/**
|
|
175
|
-
* @param {
|
|
226
|
+
* @param {WebTransportSendStream} stream
|
|
176
227
|
* @param {WritableStreamDefaultController} controller
|
|
177
228
|
*/
|
|
178
229
|
addSendStream(stream, controller) {
|
|
@@ -181,7 +232,7 @@ export class Http3WTSession {
|
|
|
181
232
|
}
|
|
182
233
|
|
|
183
234
|
/**
|
|
184
|
-
* @param {
|
|
235
|
+
* @param {WebTransportSendStream} stream
|
|
185
236
|
* @param {WritableStreamDefaultController} controller
|
|
186
237
|
*/
|
|
187
238
|
removeSendStream(stream, controller) {
|
|
@@ -190,7 +241,7 @@ export class Http3WTSession {
|
|
|
190
241
|
}
|
|
191
242
|
|
|
192
243
|
/**
|
|
193
|
-
* @param {
|
|
244
|
+
* @param {WebTransportReceiveStream } stream
|
|
194
245
|
* @param {ReadableStreamDefaultController} controller
|
|
195
246
|
*/
|
|
196
247
|
addReceiveStream(stream, controller) {
|
|
@@ -199,7 +250,7 @@ export class Http3WTSession {
|
|
|
199
250
|
}
|
|
200
251
|
|
|
201
252
|
/**
|
|
202
|
-
* @param {
|
|
253
|
+
* @param {WebTransportReceiveStream } stream
|
|
203
254
|
* @param {ReadableStreamDefaultController} controller
|
|
204
255
|
*/
|
|
205
256
|
removeReceiveStream(stream, controller) {
|
|
@@ -257,6 +308,7 @@ export class Http3WTSession {
|
|
|
257
308
|
}
|
|
258
309
|
|
|
259
310
|
onReady(/* error */) {
|
|
311
|
+
this.reliability = 'supports-unreliable'
|
|
260
312
|
if (this.readyResolve) this.readyResolve()
|
|
261
313
|
delete this.readyResolve
|
|
262
314
|
}
|
|
@@ -347,20 +399,7 @@ export class Http3WTSession {
|
|
|
347
399
|
const curres = this.resolveUniDi.shift()
|
|
348
400
|
|
|
349
401
|
if (curres != null && strobj.writable != null) {
|
|
350
|
-
|
|
351
|
-
// @ts-expect-error `getStats` property is missing from WritableStream
|
|
352
|
-
// we add it on the next line
|
|
353
|
-
const sendStream = strobj.writable
|
|
354
|
-
sendStream.getStats = () => {
|
|
355
|
-
return Promise.resolve({
|
|
356
|
-
timestamp: 0,
|
|
357
|
-
bytesWritten: 0n,
|
|
358
|
-
bytesSent: 0n,
|
|
359
|
-
bytesAcknowledged: 0n
|
|
360
|
-
})
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
curres(sendStream)
|
|
402
|
+
curres(strobj.writable)
|
|
364
403
|
}
|
|
365
404
|
}
|
|
366
405
|
}
|
|
@@ -389,7 +428,15 @@ export class Http3WTSession {
|
|
|
389
428
|
}
|
|
390
429
|
|
|
391
430
|
/**
|
|
392
|
-
* @param {
|
|
431
|
+
* @param {GoawayReceivedEvent} args
|
|
432
|
+
*/
|
|
433
|
+
onGoAwayReceived(args) {
|
|
434
|
+
if (this.drainingResolve) this.drainingResolve(undefined)
|
|
435
|
+
this.state = 'draining'
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* @param {SessionReadyEvent | SessionCloseEvent | DatagramReceivedEvent | DatagramSendEvent | GoawayReceivedEvent | NewStreamEvent} args
|
|
393
440
|
*/
|
|
394
441
|
static callback(args) {
|
|
395
442
|
// console.log('Session callback called', args)
|
|
@@ -411,6 +458,9 @@ export class Http3WTSession {
|
|
|
411
458
|
case 'DatagramSend':
|
|
412
459
|
if (visitor) visitor.onDatagramSend(args)
|
|
413
460
|
break
|
|
461
|
+
case 'GoawayReceived':
|
|
462
|
+
visitor.onGoAwayReceived(args)
|
|
463
|
+
break
|
|
414
464
|
case 'Http3WTStreamVisitor':
|
|
415
465
|
if (
|
|
416
466
|
visitor &&
|