mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
quic: add QuicEndpoint.listening & QuicStream.destroy() and tests
Starting to explore and cover the existing implementation, this covers the basic endpoint & stream lifecycle and the exposed properties. Added endpoint.listening to match net.Server and round out endpoint properties, and stream.destroy() which is already called by quicSession.destroy() and documented, but didn't actually exist. Signed-off-by: Tim Perry <pimterry@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62648 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
00705a459a
commit
f697c55e38
3 files changed
+131
-2
No files matched your search
@@ -720,7 +720,25 @@ class QuicStream {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ArrayBuffer|ArrayBufferView|Blob} outbound
|
||||
* Immediately destroys the stream. Any queued data is discarded. If an
|
||||
* error is given, the closed promise will be rejected with that error.
|
||||
* If no error is given, the closed promise will be resolved.
|
||||
* @param {any} error
|
||||
*/
|
||||
destroy(error) {
|
||||
if (this.destroyed) return;
|
||||
const handle = this.#handle;
|
||||
this[kFinishClose](error);
|
||||
handle.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the outbound data source for the stream. This can only be called
|
||||
* once and must be called before any data will be sent. The body can be
|
||||
* an ArrayBuffer, a TypedArray or DataView, or a Blob. If the stream
|
||||
* is destroyed or already has an outbound data source, an error will
|
||||
* be thrown.
|
||||
* @param {ArrayBuffer|SharedArrayBuffer|ArrayBufferView|Blob} outbound
|
||||
*/
|
||||
setOutbound(outbound) {
|
||||
if (this.destroyed) {
|
||||
@@ -1748,7 +1766,14 @@ class QuicEndpoint {
|
||||
get closing() { return this.#isPendingClose; }
|
||||
|
||||
/** @type {boolean} */
|
||||
get destroyed() { return this.#handle === undefined; }
|
||||
get listening() {
|
||||
return this.#listening;
|
||||
}
|
||||
|
||||
/** @type {boolean} */
|
||||
get destroyed() {
|
||||
return this.#handle === undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forcefully terminates the endpoint by immediately destroying all sessions
|
||||
|
||||
Reference in new issue
Block a user